home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.43k stars 29.9k forks source link

Duplicate Messages/Events Generated with Alexa Smart Home Skill Integration #67829

Closed KHouse75 closed 2 years ago

KHouse75 commented 2 years ago

The problem

A couple days ago, I upgraded to core-2022.3.1. Ever since, it appears that duplicate events with different messageIDs are being sent to the Alexa cloud when devices change state. For example I have a binary sensor for my washing machine configured and exposed to the Alexa Smart Home Skill Integration to get announcements when my washing machine cycle is complete. Because of the duplicate events, I get two Alexa announcements instead of just one. My previous HA version was core-2021.9.0

From looking through the logs, the Alexa component is duplicating everything. I've provided some of the log showing the duplicate entries.

What version of Home Assistant Core has the issue?

core-2022.3.1

What was the last working version of Home Assistant Core?

core-2021.9.0

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

Alexa Smart Home Skill Integration

Link to integration documentation on our website

https://www.home-assistant.io/integrations/alexa.smart_home/

Diagnostics information

No response

Example YAML snippet

alexa.yaml sample:

smart_home:
  locale: en-US
  endpoint: https://api.amazonalexa.com/v3/events
  client_id: amzn1.application-oa2-client.redacted
  client_secret: secret_redacted
  filter:
    include_entities:
      - light.kitchen_lights
      - light.kitchen_bar_lights
      - light.studio_lamp
      - binary_sensor.washing_machine
      - binary_sensor.washing_machine_10_minutes

Anything in the logs that might be useful for us?

2022-03-07 19:13:02 DEBUG (MainThread) [homeassistant.components.alexa.auth] Token still valid, using it
2022-03-07 19:13:02 DEBUG (MainThread) [homeassistant.components.alexa.auth] Token still valid, using it
2022-03-07 19:13:02 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Not exposing sensor.smappee_power_measurement because filtered by config
2022-03-07 19:13:02 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Not exposing sensor.smappee_power_measurement because filtered by config
2022-03-07 19:13:02 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Sent: {"event": {"header": {"namespace": "Alexa", "name": "ChangeReport", "messageId": "d535d681-afa5-42b7-afe0-0444bdd2d753", "payloadVersion": "3"}, "payload": {"change": {"cause": {"type": "APP_INTERACTION"}, "properties": [{"name": "detectionState", "namespace": "Alexa.ContactSensor", "value": "NOT_DETECTED", "timeOfSample": "2022-03-08T00:13:02.0Z", "uncertaintyInMilliseconds": 0}, {"name": "connectivity", "namespace": "Alexa.EndpointHealth", "value": {"value": "OK"}, "timeOfSample": "2022-03-08T00:13:02.0Z", "uncertaintyInMilliseconds": 0}]}}, "endpoint": {"scope": {"type": "BearerToken", "token": "Atza|redacted"}, "endpointId": "binary_sensor#washing_machine"}}}
2022-03-07 19:13:02 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Received (202):
2022-03-07 19:13:02 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Sent: {"event": {"header": {"namespace": "Alexa", "name": "ChangeReport", "messageId": "f7b4e6f4-343e-4f6f-a0bd-7fb983c51269", "payloadVersion": "3"}, "payload": {"change": {"cause": {"type": "APP_INTERACTION"}, "properties": [{"name": "detectionState", "namespace": "Alexa.ContactSensor", "value": "NOT_DETECTED", "timeOfSample": "2022-03-08T00:13:02.0Z", "uncertaintyInMilliseconds": 0}, {"name": "connectivity", "namespace": "Alexa.EndpointHealth", "value": {"value": "OK"}, "timeOfSample": "2022-03-08T00:13:02.0Z", "uncertaintyInMilliseconds": 0}]}}, "endpoint": {"scope": {"type": "BearerToken", "token": "Atza|redacted"}, "endpointId": "binary_sensor#washing_machine"}}}
2022-03-07 19:13:02 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Received (202):
2022-03-07 19:13:03 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Not exposing sensor.smappee_power_measurement because filtered by config
2022-03-07 19:13:03 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Not exposing sensor.smappee_power_measurement because filtered by config
2022-03-07 19:13:04 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Not exposing sensor.mediacenter_pc_hs110_05_current_consumption because filtered by config
2022-03-07 19:13:04 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Not exposing sensor.mediacenter_pc_hs110_05_current_consumption because filtered by config
2022-03-07 19:13:04 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Not exposing sensor.mediacenter_pc_hs110_05_voltage because filtered by config
2022-03-07 19:13:04 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Not exposing sensor.mediacenter_pc_hs110_05_voltage because filtered by config
2022-03-07 19:25:22 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Sent: {"event": {"header": {"namespace": "Alexa", "name": "ChangeReport", "messageId": "e38ef46d-8482-483f-8025-c2a0281e05e9", "payloadVersion": "3"}, "payload": {"change": {"cause": {"type": "APP_INTERACTION"}, "properties": [{"name": "powerState", "namespace": "Alexa.PowerController", "value": "ON", "timeOfSample": "2022-03-08T00:25:22.0Z", "uncertaintyInMilliseconds": 0}, {"name": "brightness", "namespace": "Alexa.BrightnessController", "value": 20, "timeOfSample": "2022-03-08T00:25:22.0Z", "uncertaintyInMilliseconds": 0}, {"name": "connectivity", "namespace": "Alexa.EndpointHealth", "value": {"value": "OK"}, "timeOfSample": "2022-03-08T00:25:22.0Z", "uncertaintyInMilliseconds": 0}]}}, "endpoint": {"scope": {"type": "BearerToken", "token": "Atza|redacted"}, "endpointId": "light#studio_lamp"}}}
2022-03-07 19:25:22 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Received (202):
2022-03-07 19:25:22 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Sent: {"event": {"header": {"namespace": "Alexa", "name": "ChangeReport", "messageId": "b1470286-4248-43f7-9304-11f780411a37", "payloadVersion": "3"}, "payload": {"change": {"cause": {"type": "APP_INTERACTION"}, "properties": [{"name": "powerState", "namespace": "Alexa.PowerController", "value": "ON", "timeOfSample": "2022-03-08T00:25:22.0Z", "uncertaintyInMilliseconds": 0}, {"name": "brightness", "namespace": "Alexa.BrightnessController", "value": 20, "timeOfSample": "2022-03-08T00:25:22.0Z", "uncertaintyInMilliseconds": 0}, {"name": "connectivity", "namespace": "Alexa.EndpointHealth", "value": {"value": "OK"}, "timeOfSample": "2022-03-08T00:25:22.0Z", "uncertaintyInMilliseconds": 0}]}}, "endpoint": {"scope": {"type": "BearerToken", "token": "Atza|redacted"}, "endpointId": "light#studio_lamp"}}}
2022-03-07 19:25:22 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Received (202):


### Additional information

_No response_
KHouse75 commented 2 years ago

While troubleshooting this issue by going through the previous releases of the alexa components by placing in custom_components, all worked as expected. After removing alexa from custom_components, the integrated copy no longer duplicates messages.

Closing this issue as everything is working as expected now.

KHouse75 commented 2 years ago

Reopening because this is still occuring. The duplicate events started again shortly after closing this issue. Others on the Community site have also reported the same problem.

oeiber commented 2 years ago

Update:

probot-home-assistant[bot] commented 2 years ago

alexa documentation alexa source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @home-assistant/cloud, @ochlocracy, mind taking a look at this issue as it has been labeled with an integration (alexa) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

KHouse75 commented 2 years ago

There was never a resolution and nobody bothered looking into it that I can tell.

I switched from notification to having alexa "Say" the message and it no longer duplicates.

This problem still exists, however. I just used a workaround.

oeiber commented 2 years ago

I'm also a bit tired, because nobody seems to care about the problem. Maybe we're the only ones having the issue or using alexa's doorbell announcement ;-). As I already saied, after restarting homeassistant the announcements where played only once. The problem occours after the alexa skill starts a discovery event. After that there must be shomething happen on the homeassistant eventbus. Because as we can see in the logfile homeassistant sends two events with different ids to the alexa proactive event api. @balloob What information can we deliver to fix the issue? Thanks a lot!

KHouse75 commented 2 years ago

I'm also a bit tired, because nobody seems to care about the problem. Maybe we're the only ones having the issue or using alexa's doorbell announcement ;-). As I already saied, after restarting homeassistant the announcements where played only once. The problem occours after the alexa skill starts a discovery event. After that there must be shomething happen on the homeassistant eventbus. Because as we can see in the logfile homeassistant sends two events with different ids to the alexa proactive event api. @balloob What information can we deliver to fix the issue? Thanks a lot!

Same here...When I restart home assistant, I only get 1 announcement. Once alexa does a discovery or I tell her to discover new devices, she duplicates announcements and I see duplicate ids when an event is triggered in home assistant.

murkumurdok commented 2 years ago

I had this issue too but when I realized no fix was imminent I just switched to using the Alexa Media Player custom component through HACS. I haven't had any problem since then.

KHouse75 commented 2 years ago

I tried a custom Alexa integration and it would stop working and kept prompting with a captcha to re-authenticate. Eventually, it locked out my amazon account and I had to reset my password. Some mentioned that after switching the 2fa the problem stopped but I moved to an alternative which was to create ESP8266 based devices that receive an audio stream and play it through a speaker. That was a pain to manage so I switched to the alexa integration with home assistant.

Tho85 commented 2 years ago

I could reproduce the issue locally and have added a fix (see #74930). Feel free to test the code there.