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

Issue when running test (Command: python3 #11

Closed CyberPoison closed 3 years ago

CyberPoison commented 3 years ago

Hi, i'm getting issue when i running the command python3 ./hass_radarr_search_by_voice.py "The Secrets of 007" "0" this is what i get.

Traceback (most recent call last):
  File "./hass_radarr_search_by_voice.py", line 294, in <module>
    downloader = MovieDownloader(query, int(mode))
  File "./hass_radarr_search_by_voice.py", line 83, in __init__
    self.tts_google("No recent movie found. Try with the command Search movie.")
  File "./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 "/home/homeassistant/.local/lib/python3.7/site-packages/requests/api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/home/homeassistant/.local/lib/python3.7/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/homeassistant/.local/lib/python3.7/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/homeassistant/.local/lib/python3.7/site-packages/requests/sessions.py", line 637, in send
    adapter = self.get_adapter(url=request.url)
  File "/home/homeassistant/.local/lib/python3.7/site-packages/requests/sessions.py", line 730, in get_adapter
    raise InvalidSchema("No connection adapters were found for {!r}".format(url))
requests.exceptions.InvalidSchema: No connection adapters were found for 'localhost:8123/api/services/tts/google_translate_say'

I have set everything unless api but i use token so this is my config

import datetime
import requests
import json
import sys
import os

# User defined variables

# Home assistant URL eg. localhost:8123 with port
HASS_SERVER="localhost:8123"

# Home assistant legacy api password
HASS_API="" # leave blank if using long-lived token

# Home assistant long-lived token
HASS_TOKEN="eyJ0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

# Home assistant scripts path eg. /users/vr/.homeassistant/scripts
HASS_SCRIPTS_PATH="/home/homeassistant/.homeassistant/scripts/"

# Home assistant google home entity_id  eg. media_player.family_room_speaker
HASS_GOOGLE_HOME_ENTITY="media_player.salle_tv"

RADARR_SERVER="publicIP.external:30958" # with port
RADARR_API="xxxxxxxxxxxxxxxxxxxx"
RADARR_DOWNLOAD_PATH="/mnt/unionfs/FR/Films[FR]" # aka rootFolderPath
RADARR_QUALITY_PROFILE_ID=4  # 1080p

TMDBID_API="dfadxxxxxxxxxxxxxxxxx"

Can you tell me what i get the issue more above in this issue ticket ?

CyberPoison commented 3 years ago

get also this when using default (.yaml files)

2020-11-04 20:59:31 ERROR (SyncWorker_0) [homeassistant.util.yaml.loader] while parsing a block mapping
  in "/home/homeassistant/.homeassistant/automations.yaml", line 1, column 3
expected <block end>, but found '<block mapping start>'
  in "/home/homeassistant/.homeassistant/automations.yaml", line 2, column 5
2020-11-04 20:59:31 ERROR (MainThread) [homeassistant.bootstrap] Failed to parse configuration.yaml: while parsing a block mapping
  in "/home/homeassistant/.homeassistant/automations.yaml", line 1, column 3
expected <block end>, but found '<block mapping start>'
  in "/home/homeassistant/.homeassistant/automations.yaml", line 2, column 5. Activating safe mode
2020-11-04 20:59:35 WARNING (MainThread) [homeassistant.bootstrap] Support for the running Python version 3.7.3 is deprecated and will be removed in the first release after December 7, 2020. Please upgrade Python to 3.8.0 or higher.
avraham commented 3 years ago

Hi, I think there are 2 problems.

First, there are several options (modes) for second parameter. In this case, since the movie is more than 3 years old the right use would be mode "1". I decided to only use mode 0 for recent/new movies because it narrows the search options a lot making the guess really accurate otherwise undesired results might be more common . If you have basic coding knowledge you can try adjusting the number of years to be considered for mode 0.

The second problem is the name of the text to speech service. You probably changed the default name on your Home Assistant configuration file. Here someone else had the same problem. https://github.com/avraham/hass_radarr_search_by_voice/issues/8#issuecomment-675074841

CyberPoison commented 3 years ago

I have set my configuration.yaml like this

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate
    cache: true
    cache_dir: /tmp/tts
    time_memory: 300
    base_url: http://192.168.1.1:8123
    service_name: google_translate_say

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

Sorry i forget to post it there

it return the same issue when i try it with def conf (empty tts:)

  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 731, in get_adapter
    raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for '192.168.1.1:8123/api/services/tts/google_translate_say'

even with service name as set: google_translate_say

my hassio version is Home Assistant 0.117.4 using docker

avraham commented 3 years ago

I found the issue and already pushed the changes to the repository. You can see the changed lines here https://github.com/avraham/hass_radarr_search_by_voice/commit/b1d704e11fe6a856cc02b70a821cee2a888d2ea1

Thanks for pointing this out.

CyberPoison commented 3 years ago

Thank to the push 👍 after some test it works by cli need to figure out why by IFTTT it doesn't work .

When i execute vocal search i get this.

First occurred: 13:29:11 (2 occurrences)
Last logged: 13:44:18

ITFTTMovies: Error executing script. Service not found for call_service at pos 1: Unable to find service shell_command/download_movie
Home Assistant já iniciou

i guess i need to add some service for that not sure how to do that

CyberPoison commented 3 years ago

Ok after working on it i have set up it on Home Assisntant but it don't adds movie when i do search by voice. Can you tell me if this is correct ?

{ "action": "call_service", "service": "script.download_movie", "data": " TextField "}

I don't get any log about the runtime of the script or python when i execute the search by voice do you have any suggestion ?

I have tranlated all data in Enlgish to french btw, so it's supposed to get back some info from the google home after saying.

Telecharge moi le film "No Time to Die"

and i have it set like this on IFTTT

Telecharge le film $
avraham commented 3 years ago

Ok. You are using docker, right?. I believe you just can't execute shell scripts as usual and have to do it via ssh. (I actually don't know as I'm not using docker for HA) This might help. Run it from Docker https://community.home-assistant.io/t/quotes-ssh-and-docker-shell-commands/234935

CyberPoison commented 3 years ago

Thank for the help, got it working with changing The line 19 on automation.yaml

movie:  "{{ trigger.event.data['movie'] }}"

And changing the ifttt body from data to movie

Based in you work I will try to put it working with sonarr pvr if I get some free time for that purpose 😉

avraham commented 3 years ago

I'm glad you got it working. A Sonarr script would be awesome. I_ve been thinking about it for a long time, but I don't download too many series. Still, let me know if I can help.