It’s best to build code in steps: verify one piece is working before adding complexity to it. In this case, get the action working with a hardcoded variable first, and then figure out how to pass a template into the variable.
That is what Didgeridrew was asking. Go to developer tools → actions, select your rest command, and switch to YAML mode. There you can add the variable, and use something hardcoded for now, and something that doesn’t need url-encoding so you can avoid that pitfall for now as well:
action: rest_command.web_search
data:
query: weather
response_variable: result
If that works, then you can start adding complexity, like url encoding and then passing variables.
Regarding url encoding, since skip_url_encoding is set to false by default (per the docs), you probably don’t need your template to do that.
That is the response you’re getting from Google. I don’t know what that service is, so it’s difficult for me to help you with that part. HA is doing what you are telling it to do. If I run the command I get a 400 error because my credentials are made-up, or I get 403 when I exclude them entirely.
You might try to execute your query using CURL in a terminal window (rather than a browser), so that you verify exactly what needs to be sent.
You got it, something was wrong with my custom search engine, the key they generated looked shorter than another key i had. So i used my older key and it worked. thanks!
Well, almost gotta fix my automation now.
Update: It “works”. But Voice Assistant can’t parse the spoken query. I can type a search as a conversation and even hard code a voice query. But it seems that unless it’s written down, Voice Assistant (at least through a ReSpeaker satellite) can’t parse the query.
Any way this could be worked around? Obviously an LLM or HA Cloud are solutions, but you see Ollama barely runs on this old AMD thin client, I don’t have spare GPUs or money for such things and not interested in paying more subscriptions.