avraham / hass_radarr_sonarr_search_by_voice

Add movies to radarr by voice
GNU General Public License v3.0
46 stars 8 forks source link

How to call from google assistant #8

Closed sgtstadanko closed 3 years ago

sgtstadanko commented 4 years ago

hi,

So I have this working on command line from the Readme as well as working via call service from hass developer tools as outlined in another support request.

How does one call it verbally from Google assistantant/speaker?

Thanks, Bill

sgtstadanko commented 4 years ago

Additionally I can say "ok,Google turn on download movie" and it activates the script but it won't let me say "ok, google turn on download movie . It thinks that is random command and usually pulls up description of streaming services. Its all exposed to hass.io...

sgtstadanko commented 4 years ago

More info. If I say ok, google turn on download movie. It says ok activating download movie and waits for voice input. Sometime this adds the movie sometime not but always adds unmonitored so it doesn't download automatically. The other thing is it doesn't do the same google tts speech bits that running the script does, so I feel like something isn't setup quite right.

avraham commented 4 years ago

I just updated the last section of the Readme on how to use with Google Assistant. I added an updated screenshot of an ifttt applet example.

avraham commented 4 years ago

Also, if the command line test works, it should not be an issue with the IFTTT integration.

sgtstadanko commented 4 years ago

Thanks for the reply and for the ifttt info. I didn't realize you had to integrate ifttt and Google assistant to get it to work. I'll give it a go!

sgtstadanko commented 4 years ago

Yay! That worked great! Whats the secret sauce to get it to add movie as monitored. With out that it wonf search? Seach and Add would be even better than just monitored so it would start downloading.

avraham commented 4 years ago

I'm glad it worked. I only add movies as monitored and I don't force a search by choice, but I can add it as an option. I guess that feature might be helpful for some people.

On Sun, Aug 16, 2020, 9:41 PM sgtstadanko notifications@github.com wrote:

Yay! That worked great! Whats the secret sauce to get it to add movie as monitored. With out that it wonf search? Seach and Add would be even better than just monitored so it would start downloading.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/avraham/hass_radarr_search_by_voice/issues/8#issuecomment-674651513, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQAXB6CYIJIDSIZYGYQJDTSBCYIJANCNFSM4QABN4WA .

avraham commented 4 years ago

Just to be clear. The movies are not added as monitored?, Because they should be added as monitored

sgtstadanko commented 4 years ago

correct. i added a couple of movies and they all showed up as unmonitored.

avraham commented 4 years ago

what version of radarr are you using?

sgtstadanko commented 4 years ago

0.2.0.1504

sgtstadanko commented 4 years ago

its odd. sometimes it adds as monitored sometime not.

unrelated but with latest code when running via cli , it no longer adds and i get

bash-5.0# ./download.sh "Deep Blue Sea 3" "1"
Traceback (most recent call last):
  File "/config/hass_radarr_search_by_voice.py", line 294, in <module>
    downloader = MovieDownloader(query, int(mode))
  File "/config/hass_radarr_search_by_voice.py", line 94, in __init__
    self.tts_google(msg)
  File "/config/hass_radarr_search_by_voice.py", line 270, in tts_google
    r = requests.post(HASS_SERVER+"/api/services/tts/google_translate_say",json.dumps(data), headers=headers)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 637, in send
    adapter = self.get_adapter(url=request.url)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 728, in get_adapter
    raise InvalidSchema("No connection adapters were found for {!r}".format(url))
requests.exceptions.InvalidSchema: No connection adapters were found for '192.168.1.214:8123/api/services/tts/google_translate_say'

i notice in this last line google_say became google_translate_say?

this is my configuration.yaml def for google translate that i copied from hass setup doc:

# Text to speech
tts:
  - platform: google_translate
    cache: true
    cache_dir: /tmp/tts
    time_memory: 300
    service_name: google_say

This was working before update

The diff:

bash-5.0# diff hass_radarr_search_by_voice.py hass_radarr_search_by_voice.py.ok
--- hass_radarr_search_by_voice.py
+++ hass_radarr_search_by_voice.py.ok
@@ -267,10 +267,10 @@
             headers = {
                 'Authorization': 'Bearer '+HASS_TOKEN
             }
-            r = requests.post(HASS_SERVER+"/api/services/tts/google_translate_say",json.dumps(data), headers=headers)
+            r = requests.post("http://"+HASS_SERVER+"/api/services/tts/google_say",json.dumps(data), headers=headers)

         else:
-            r = requests.post(HASS_SERVER+"/api/services/tts/google_translate_say?api_password="+HASS_API,json.dumps(data))
+            r = requests.post("http://"+HASS_SERVER+"/api/services/tts/google_say?api_password="+HASS_API,json.dumps(data))

         # assistant-relay

Not a huge deal but was trying to get that audio confirmation back to the speaker when adding. adding still works with the ifttt applet.

When i changed it back to

r = requests.post("http://"+HASS_SERVER+"/api/services/tts/google_say?api_password="+HASS_API,json.dumps(data))

It works. Not even sure if the google speaker is supposed to get these response when you execute via the IFTTT applet anyway.

avraham commented 4 years ago

I see, the default name of the service is "google_translate_say", but since in your configuration you specify a different service name (google_say) that causes the error. https://www.home-assistant.io/integrations/tts/#service_name

When I first wrote the script the service name was google_say, but they changed and I updated it too. Yes, you are supposed to get feedback through the google speaker. If you use the service google_say for some others things, changing the code as you did would be a quick fix.

This has nothing to do with the monitored/unmonitored issue. I would need to investigate on that. If you notice if it happens under specific conditions that would help.

sgtstadanko commented 4 years ago

Thanks! Its all working now with google_say back out the speaker after IFTTT applet runs. I will keep an eye on monitored vs unmonitored and see if I can reproduce for you. Now i just need to see about adding/ creating applets for the movie search with multiple options.

wonder if some of your existing code could be copied over to a Sonarr section as well? If i have time will look at that too.