Uses the Brave search api to ask the Home Assistant Voice Assistant simple questions and get meaningful results.
The flow for this is a little convoluted because accessing the correct Home Assistant properties in the correct places proved tricky.
- A custom intent script
AskQuestion
detects that a question is being asked and pipes the question to a custom Home Assistant Scriptask_question
ask_question
sends the question to a custom servicebrave_summarizer
which makes the web request to Brave Searchbrave_summarizer
returns the question, summary, and sources to the scriptask_question
in the variablebrave_response
ask_question
then calls the python_script.set_state 3 times in parallel to update template sensorsquestion_asked
,answer_summary
, andanswer_sources
.- the intent script
AskQuestion
now considers the process complete and answers the user from a template which uses sensorsanswer_summary
andanswer_sources
.
- Set up an intent script under
custom_sentences
that will intercept the question type and wildcard (this is broken into two parts so we don't just put a wildcard as the base) - Configure the custom
summarizer_service
including setting theX-Subscription-Token
- Update the
configuration.yaml
with sensors that will hold the values for thequestion_asked
, theanswer_summary
, and theanswer_sources
. I used a template type that updates at midnight just so the question does hang out forever - Update the
configuration.yaml
to include python scripts - Include a python script to update the state from a script. I used the implementation provided by Rod Payne
- Update the
configuration.yaml
to include the custombrave_summarizer
- Update the
configuration.yaml
to include theintent_script
:AskQuestion
- Update
scripts.yaml
to include theask_question
script (Just paste it onto the bottom)