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

Multiple Errors #1697

Closed oneseventhree closed 2 years ago

oneseventhree commented 2 years ago

Hi,

Without my HA server has been running properly for days but just today I have been getting these errors without anything changing on my end:

Screen Shot 2022-08-30 at 9 12 35 pm

First TTS stopped working but now thats back up and running but then I wasn't able to trigger routines even though TTS was working.

AS of 5 minutes ago everything seems to be working but things are out of service time to time

Ottomaane commented 2 years ago

same here

AlexKusnezov commented 2 years ago

same here I'm not able to trigger routines for 2 hours now, constantly getting this:

Unable to find referenced entities media_player.alexa_wohnzimmer or it is/they are currently not available
brinzlee commented 2 years ago

I keep getting Alexa Media Player Requires Attention....and the following in the log.... I have entered all the detail including OTP several times now.......works for an hour or so then bombs out...

`Logger: alexapy.helpers Source: custom_components/alexa_media/media_player.py:618 Integration: Alexa Media Player (documentation, issues) First occurred: 2:35:43 PM (1 occurrences) Last logged: 2:35:43 PM

alexaapi.get_state((<alexapy.alexaapi.AlexaAPI object at 0x7f6f3c7dc0>,), {}): An error occured accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments: ('Login error detected; not contacting API',)`

dpgh947 commented 2 years ago

There may be problems at Amazon, I have had to keep re-authing Alexa daily for the past 3 days, twice today. Getting similar sorts of errors in my logs too.

MikeGuest commented 2 years ago

Well, this is interesting (may be same issue) - notice the correct integration to the right

Earlier today I logged into amazon on each of these and they disappeared as I did so - and now they're back again.

cropped Screenshot from 2022-08-31 19-38-54

can raise it as a separate issue if required - but it sounds somewhat related given the recency of these other issues

nima-1102 commented 2 years ago

I have exactly the same problems, if you want to reload the integration, the following message appears:

Logger: homeassistant.config_entries Source: custom_components/alexa_media/media_player.py:280 Integration: Alexa Media Player (documentation, issues) First occurred: 09:09:12 (1 occurrences) Last logged: 09:09:12

Error unloading entry Amazon Alexa for media_player Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 496, in async_unload result = await component.async_unload_entry(hass, self) File "/usr/src/homeassistant/homeassistant/components/media_player/init.py", line 430, in async_unload_entry return await component.async_unload_entry(entry) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 174, in async_unload_entry await platform.async_reset() File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 687, in async_reset await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 798, in async_remove await self.async_will_remove_from_hass() File "/config/custom_components/alexa_media/media_player.py", line 280, in async_will_remove_from_hass coordinator.async_remove_listener(self.update) AttributeError: 'DataUpdateCoordinator' object has no attribute 'async_remove_listener'

This seems to be causing the problem:

2022-09-01 04:42:56.362 WARNING (MainThread) [alexapy.helpers] alexaapi.get_activities((<alexapy.alexalogin.AlexaLogin object at 0x7f0f64ec0cd0>, 10), {}): A login error occured: An exception of type JSONDecodeError occurred. Arguments: ('Expecting value: line 1 column 1 (char 0)',) 2022-09-01 04:42:56.373 WARNING (MainThread) [alexapy.helpers] alexaapi.get_last_device_serial((<alexapy.alexalogin.AlexaLogin object at 0x7f0f64ec0cd0>,), {}): An error occured accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments: ()

rremmelts commented 2 years ago

Same error here after the latest HA update 😓

SonnyBBQ commented 2 years ago

Same issue here. Have tried re-authing, but the issue returns same day.

Anything else we can do to add to the info?

sammyke007 commented 2 years ago

+1

mfabiani53 commented 2 years ago

+1 same issues here...

coolhansen commented 2 years ago

+1

johnbubak commented 2 years ago

+1

dpgh947 commented 2 years ago

I've had a quick look at the changes in 4.1.0 and there's a lot in the auth/reauth area. I've reverted to 4.0.3 and been through some re-authentications (confirmed by watching "expires_in" in core.config_entries), and some full reboots too, and it seems to be behaving.

oneseventhree commented 2 years ago

mine has been OK since I posted this. Strange how we are all getting it at different times

mfabiani53 commented 2 years ago

I am forced to reload the integration every morning and acter this fo r all the day i have no probs since the next morning.

rahaaas commented 2 years ago

Same issue. Multiple instances of reauth over last 12 hours. Announcements are working, strangely.

dpgh947 commented 2 years ago

Could still be coincidence as this problem seems intermittent and possibly regional if it really is at the amazon end, but I've still had no problems and nothing in logs since I fell back to 4.0.3 yesterday.

brinzlee commented 2 years ago

I tried rolling back to 4.0.3. but that doesn't work for me. Got the same reauthentication message 4 hours later

saveriospeziali commented 2 years ago

Hi

Same problem for me, for the moment this automation help me:

providing an existing Alexa Media Player entity to homeassistant.reload_config_entry cause the integration to reload but take into account the today in any case I had almost one authentication error

dpgh947 commented 2 years ago

I tried rolling back to 4.0.3. but that doesn't work for me. Got the same reauthentication message 4 hours later

Ok, good to know. I'm just being lucky for some reason then...

ziolelle commented 2 years ago

I think also my error is related...

Screenshot 2022-09-04 at 01 27 27

Many re-authentications needed in last days

dpgh947 commented 2 years ago

Well, that will teach me... After working fine for a day and a half, had to reauth 3 times in the past couple of hours. So definitely there on 4.0.3 too.

Toggz commented 2 years ago

I'm in the UK and constantly having to re-auth (given up). Changing the volume on an Echo for example triggers a re-auth. Sure it's a Amazon problem, hoping it'll be up and running tomorrow morning. :) 'AlexapyLoginError' throughout Log. eg...

alexaapi.get_state((<alexapy.alexaapi.AlexaAPI object at 0x7f60cb59h6k0>,), {}): An error occured accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments: ('Login error detected; not contacting API',)

Pirol62 commented 2 years ago

Same here in Germany. After a restart of HA this morning alexa started this behaviour that I have to reauth once an hour or after every use(I. E. a speech command) . Two days ago it happened only two times and then it was stable until this night. I hoped that I'm not affected. It was wrong... But it seems that Alexa is working anyway. No, correction: the function is broken.

Logger: homeassistant
Source: /usr/src/homeassistant/homeassistant/runner.py:96
First occurred: 10:00:01 (1 occurrences)
Last logged: 10:00:01

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/alexapy/helpers.py", line 141, in wrapper
    return await func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/alexapy/alexaapi.py", line 931, in send_announcement
    await self.send_sequence(
  File "/usr/local/lib/python3.10/site-packages/alexapy/helpers.py", line 141, in wrapper
    return await func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/alexapy/alexaapi.py", line 483, in send_sequence
    await self.run_behavior(node_data, queue_delay=queue_delay)
  File "/usr/local/lib/python3.10/site-packages/alexapy/helpers.py", line 141, in wrapper
    return await func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/alexapy/alexaapi.py", line 405, in run_behavior
    await self._post_request("/api/behaviors/preview", data=data)
  File "/usr/local/lib/python3.10/site-packages/alexapy/alexaapi.py", line 203, in _post_request
    return await self._request("post", uri, data)
  File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 133, in retry
    ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/alexapy/alexaapi.py", line 195, in _request
    raise AlexapyLoginError(response.reason)
alexapy.errors.AlexapyLoginError: Unauthorized

This error comes, when I try to reauth with my tablet. Via desktop everything is fine.

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: aiohttp.server
Source: custom_components/alexa_media/config_flow.py:252
Integration: Alexa Media Player (documentation, issues)
First occurred: 09:57:16 (1 occurrences)
Last logged: 09:57:16

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 82, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 177, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 109, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 277, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 359, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/alexa_media/config_flow.py", line 252, in async_step_user
    async with session.get(hass_url) as resp:
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 1138, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 422, in _request
    url = self._build_url(str_or_url)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 356, in _build_url
    url = URL(str_or_url)
  File "/usr/local/lib/python3.10/site-packages/yarl/_url.py", line 158, in __new__
    raise TypeError("Constructor parameter should be str")
TypeError: Constructor parameter should be str
dpgh947 commented 2 years ago

Completely broken for me now. Reauth, and the next alexa related event breaks it again.

DJBenson commented 2 years ago

Hi

Same problem for me, for the moment this automation help me:

  • id: "restart_alexa" alias: "Restart ALEXA MEDIA PLAYER " description: "" trigger:

    • platform: time_pattern hours: "/1" condition: [] action:
    • service: homeassistant.reload_config_entry data: {} target: entity_id: media_player.soggiorno mode: single

providing an existing Alexa Media Player entity to homeassistant.reload_config_entry cause the integration to reload but take into account the today in any case I had almost one authentication error

This seems to be holding it together for me - it seems to clear any pending reauthenticaton requests and suppresses new ones (so far...). You can pass multiple entities to the service so if you have multiple Echo devices you can call the service once for all of them.

Conversely, rolling back to 4.0.3 alone did not solve the issue - immediately after setup I was presented with the re-auth prompts.

saveriospeziali commented 2 years ago

Hi Same problem for me, for the moment this automation help me:

  • id: "restart_alexa" alias: "Restart ALEXA MEDIA PLAYER " description: "" trigger:

    • platform: time_pattern hours: "/1" condition: [] action:
    • service: homeassistant.reload_config_entry data: {} target: entity_id: media_player.soggiorno mode: single

providing an existing Alexa Media Player entity to homeassistant.reload_config_entry cause the integration to reload but take into account the today in any case I had almost one authentication error

This seems to be holding it together for me - it seems to clear any pending reauthenticaton requests and suppresses new ones (so far...). You can pass multiple entities to the service so if you have multiple Echo devices you can call the service once for all of them.

Conversely, rolling back to 4.0.3 alone did not solve the issue - immediately after setup I was presented with the re-auth prompts.

Hi, My intention was to reload the integration (in my case even a manual reload fixed te problem), I documented and using homeassistant.reload_config_entry seem the correct way, apparently to reload it is sufficient to pass a single entity among the existing ones..

Regards

dpgh947 commented 2 years ago

I am getting multiple integrations appearing alongside the real one now. I tried going through configure for these 3, got down to one then the real one complained and I now have 4...

image

alanmilinovic commented 2 years ago

I am getting multiple integrations appearing alongside the real one now. I tried going through configure for these 3, got down to one then the real one complained and I now have 4...

image

Delete the one that is not red. Restart HA and create new integration. Repeat this process until you stabilize it. I had to do it like 3 times today in the morning.

alanmilinovic commented 2 years ago

This is the automation that I have created not just for Alexa but for many other integrations that are not stable.

alias: "Reload: Reload Alexa Media Player on unavailable"
description: >-
  Check every 5 minutes if Alexa entity is unavailable for more than 1 minute.
  If yes, then reload Alexa integration.
trigger:
  - platform: time_pattern
    minutes: /5
condition:
  - condition: state
    state: unavailable
    for:
      hours: 0
      minutes: 1
      seconds: 0
    entity_id: media_player.alans_echo_dot
action:
  - service: homeassistant.reload_config_entry
    data: {}
    target:
      entity_id: media_player.alans_echo_dot
mode: restart
Pirol62 commented 2 years ago

Very good idea, but: Can we assume, that in case of Alexa all devices turn to unavailable so that we only monitor one of them? Then it would avoid a lot of errors due to unique key issues when Alexa reloads entities which already exists in case of simply reloading once an hour even it is not really necessary at that time

alanmilinovic commented 2 years ago

Very good idea, but: Can we assume, that in case of Alexa all devices turn to unavailable so that we only monitor one of them? Then it would avoid a lot of errors due to unique key issues when Alexa reloads entities which already exists in case of simply reloading once an hour even it is not really necessary at that time

I just created the script and will monitor to see if the echo dot is unavailable. Might be also better to check for "device_tracker.amazon_alexa" entitiy instead, however, reloading every hour looks a bit too heavy to me.

Pirol62 commented 2 years ago

Agree

oneseventhree commented 2 years ago

@alandtse can you tell us what issue # this a duplicate of so we can follow the progress?

alandtse commented 2 years ago

I assume #1701. Your initial report was incomplete so honestly not sure what the error is you're reporting, but all the replies have been tied to the EU auth issue.

If that's not what you're experiencing, please create a new issue with a complete template. Screenshots of issues aren't searchable.