alandtse / alexa_media_player

This is a custom component to allow control of Amazon Alexa devices in Home Assistant using the unofficial Alexa API.
Apache License 2.0
1.51k stars 289 forks source link

Tts not working on version 3.8.0 and above #1206

Closed joselito11 closed 3 years ago

joselito11 commented 3 years ago

Describe the bug Tts not working on version 3.8.0 and above

To Reproduce Steps to reproduce the behavior:

  1. Go to 'alexa media player'
  2. Click on 'write some text and click send'
  3. See error

System details

Logs

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/alexa_media/media_player.py:1216
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 17:25:01 (1 occurrences)
Last logged: 17:25:01

[140099281512624] 'NoneType' object has no attribute 'async_create_task'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 141, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1488, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1523, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/components/notify/__init__.py", line 154, in _async_notify_message_service
    await self.async_send_message(**kwargs)
  File "/config/custom_components/alexa_media/notify.py", line 292, in async_send_message
    await asyncio.gather(*tasks)
  File "/config/custom_components/alexa_media/helpers.py", line 157, in _catch_login_errors
    result = await func(*args, **kwargs)
  File "/config/custom_components/alexa_media/media_player.py", line 1216, in async_send_tts
    self.hass.async_create_task(
AttributeError: 'NoneType' object has no attribute 'async_create_task'

Additional context Last working version is 3.6.4. I have today tried with latest 3.8.3 - no tts, but have then downgraded to 3.6.4

mattlward commented 3 years ago

I have the same issue, worked great with 3.8.0, but will not work with anything higher. I tried .1, .2 and .3. Seems to be an authentication issue to me.

I am not running with Amazon 2FA enabled.

System Info:

System Health

version: core-2021.3.3
installation_type: Home Assistant Supervised
dev: false
hassio: true
docker: true
virtualenv: false
python_version: 3.8.7
os_name: Linux
os_version: 4.19.0-13-amd64
arch: x86_64
timezone: America/Chicago

GitHub API: ok
Github API Calls Remaining: 5000
Installed Version: 1.11.3
Stage: running
Available Repositories: 748
Installed Repositories: 11

host_os: Debian GNU/Linux 10 (buster)
update_channel: stable
supervisor_version: supervisor-2021.03.4
docker_version: 20.10.2
disk_total: 218.1 GB
disk_used: 10.4 GB
healthy: true
supported: true
supervisor_api: ok
version_api: ok
installed_addons: Backup Hassio to Google Drive (1.7.2), Dropbox Sync (1.3.0), Duck DNS (1.12.5), FTP (4.0.1), File editor (5.2.0), Log Viewer (0.9.1), RPC Shutdown (2.2), WireGuard (0.5.0), Mosquitto broker (5.1.1), SSH & Web Terminal (8.0.3), Samba share (9.3.1), TasmoAdmin (0.14.0), motionEye (0.11.1), AdGuard Home (4.0.0), Portainer (1.4.0), Glances (0.11.1), Check Home Assistant configuration (3.6.0), DHCP server (1.2), Network UPS Tools (0.6.2)

dashboards: 1
resources: 4
views: 16
mode: storage

Coming int severe storm season, and ran a test and found it broken. Will stay on 3.8.0 for now.

Logs

2021-03-11 14:30:58 WARNING (MainThread) [alexapy.helpers] alexaapi.get_last_device_serial((<alexapy.alexalogin.AlexaLogin object at 0x7fcd0ce36ac0>,), {}): A login error occured: An exception of type JSONDecodeError occurred. Arguments:
('Expecting value: line 1 column 1 (char 0)',)
2021-03-11 14:31:17 WARNING (MainThread) [alexapy.helpers] alexaapi.run_behavior((<alexapy.alexaapi.AlexaAPI object at 0x7fcd0e681be0>, {'@type': 'com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode', 'type': 'Alexa.DeviceControls.Volume', 'operationPayload': {'deviceType': 'A3S5BH2HU6VAYF', 'deviceSerialNumber': 'G************PV2', 'locale': 'en-us', 'customerId': 'A**********WYW', 'value': 50.0}}), {'queue_delay': 1.5}): An error occured accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
('Login error detected; not contacting API',)
2021-03-11 14:31:17 WARNING (MainThread) [alexapy.helpers] alexaapi.send_sequence((<alexapy.alexaapi.AlexaAPI object at 0x7fcd0e681be0>, 'Alexa.DeviceControls.Volume'), {'customer_id': 'A2F5JRZGL4BWYW', 'value': 50.0, 'queue_delay': 1.5}): An error occured accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
('Login error detected; not contacting API',)
2021-03-11 14:31:17 WARNING (MainThread) [alexapy.helpers] alexaapi.set_volume((<alexapy.alexaapi.AlexaAPI object at 0x7fcd0e681be0>, 0.5), {}): An error occured accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
('Login error detected; not contacting API',)
2021-03-11 14:31:17 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/alexapy/helpers.py", line 144, in wrapper
    return await func(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/alexapy/alexaapi.py", line 1071, in set_volume
    await self.send_sequence(
  File "/usr/local/lib/python3.8/site-packages/alexapy/helpers.py", line 144, in wrapper
    return await func(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/alexapy/alexaapi.py", line 475, in send_sequence
    await self.run_behavior(node_data, queue_delay=queue_delay)
  File "/usr/local/lib/python3.8/site-packages/alexapy/helpers.py", line 144, in wrapper
    return await func(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/alexapy/alexaapi.py", line 397, in run_behavior
    await self._post_request("/api/behaviors/preview", data=data)
  File "/usr/local/lib/python3.8/site-packages/alexapy/alexaapi.py", line 201, in _post_request
    return await self._request("post", uri, data)
  File "/usr/local/lib/python3.8/site-packages/backoff/_async.py", line 133, in retry
    ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/alexapy/alexaapi.py", line 171, in _request
    raise AlexapyLoginError("Login error detected; not contacting API")
alexapy.errors.AlexapyLoginError: Login error detected; not contacting API
alandtse commented 3 years ago

Please provide your startup logs plus logs trying the tts call. The instructions are linked in the template.

mattlward commented 3 years ago

I assume you want the logs with 3.8.3 installed?

alandtse commented 3 years ago

Yes please. I need to see the non working call. Please also note your issue is different then the one reported originally. You're having a login error, but assuming you log in and have the problem I can look at it.

mattlward commented 3 years ago

I have not been using 2FA and I suppose I could switch, but really did not want to.

Ok, so I enabled logging, upgraded to 3.8.3 and rebooted... Now it works! alexa_media.zip

The zip includes the .html files, and logs from boot thru making a test call. Going to remove all the added logging and see if it keeps working.

Attempting the following changes to configuration.yaml

#    custom_components.alexa_media: debug  
# for API debugging (verbose and intended for service debugging)
#    alexapy: debug
# for proxy debugging
#    authcaptureproxy: debug

alexa_media:
  accounts:
    - email: me@gmail.com    
      password: xxxxx
      url: amazon.com
      debug: False

Results in the following error

Logger: alexapy.alexalogin
Source: /usr/local/lib/python3.8/site-packages/alexapy/alexalogin.py:696
First occurred: 9:38:21 AM (1 occurrences)
Last logged: 9:38:21 AM

No access token found; falling back to credential login instead of oauth.

Changed config to the following and now the error is gone and I can reboot and it still works on 3.8.3.

  logs:
    custom_components.alexa_media: warning 
# for API debugging (verbose and intended for service debugging)
    alexapy: warning
# for proxy debugging
    authcaptureproxy: warning

alexa_media:
  accounts:
    - email: me@gmail.com    
      password: xxxx
      url: amazon.com
      debug: True
joselito11 commented 3 years ago

Again broken: `Logger: homeassistant.components.script.obvestilo_tablete_oce_dot Source: custom_components/alexa_media/media_player.py:1223 Integration: Skripta (documentation, issues) First occurred: 7:00:10 (2 occurrences) Last logged: 7:00:30

obvestilo_tablete_oce_dot: Error executing script. Unexpected error for call_service at pos 2: 'NoneType' object has no attribute 'async_create_task' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 262, in _async_step await getattr( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 463, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1488, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1523, in _execute_service await handler.job.target(service_call) File "/usr/src/homeassistant/homeassistant/components/notify/init.py", line 154, in _async_notify_message_service await self.async_send_message(kwargs) File "/config/custom_components/alexa_media/notify.py", line 292, in async_send_message await asyncio.gather(tasks) File "/config/custom_components/alexa_media/helpers.py", line 157, in _catch_login_errors result = await func(args, kwargs) File "/config/custom_components/alexa_media/media_player.py", line 1223, in async_send_announcement self.hass.async_create_task( AttributeError: 'NoneType' object has no attribute 'async_create_task'

`

avdept commented 3 years ago

@joselito11 how did you fix it?

joselito11 commented 3 years ago

@avdept problem is still there with never versions https://github.com/custom-components/alexa_media_player/issues/1221

avdept commented 3 years ago

@joselito11 I got it working using following approach

service: notify.alexa_media_alex_s_echo_dot
data:
  message: 'Your message goes here'
  target: media_player.alex_s_echo_dot
  data:
    type: tts