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
73.68k stars 30.8k forks source link

Arming security system from Alexa results in an error if the system is already armed in that mode #129700

Closed natekspencer closed 1 week ago

natekspencer commented 1 week ago

The problem

I have a routine that I run at night from Alexa where one of the steps is to arm my security system in stay mode. If I run it again (or if the system is already armed), I get an error response from Alexa saying: "Hmm, is not responding."

What version of Home Assistant Core has the issue?

core-2024.10.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

alexa

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-11-02 15:27:55.287 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Sent: {"event": {"header": {"namespace": "Alexa", "name": "ChangeReport", "messageId": "2794d690-3604-4fbe-8164-b277acd1f0eb", "payloadVersion": "3"}, "payload": {"change": {"cause": {"type": "APP_INTERACTION"}, "properties": [{"name": "armState", "namespace": "Alexa.SecurityPanelController", "value": "DISARMED", "timeOfSample": "2024-11-02T21:27:55Z", "uncertaintyInMilliseconds": 0}, {"name": "connectivity", "namespace": "Alexa.EndpointHealth", "value": {"value": "OK"}, "timeOfSample": "2024-11-02T21:27:55Z", "uncertaintyInMilliseconds": 0}]}}, "endpoint": {"scope": {"type": "BearerToken", "token": "**REDACTED**"}, "endpointId": "alarm_control_panel#spencer_estates"}}}
2024-11-02 15:28:40.786 DEBUG (MainThread) [homeassistant.components.alexa.smart_home] Received Alexa Smart Home request: {'directive': {'header': {'namespace': 'Alexa.SecurityPanelController', 'name': 'Arm', 'payloadVersion': '3', 'messageId': '5a76e393-6b26-4cc6-b2da-c7b8e727d4d5', 'correlationToken': '**REDACTED**'}, 'endpoint': {'scope': {'type': 'BearerToken', 'token': '**REDACTED**'}, 'endpointId': 'alarm_control_panel#spencer_estates', 'cookie': {}}, 'payload': {'armState': 'ARMED_STAY'}}}
2024-11-02 15:28:40.789 DEBUG (MainThread) [homeassistant.components.alexa.smart_home] Sending Alexa Smart Home response: {'event': {'header': {'namespace': 'Alexa.SecurityPanelController', 'name': 'Arm.Response', 'messageId': '0fba1296-4a3e-48d7-ab56-e975663f64e6', 'payloadVersion': '3', 'correlationToken': '**REDACTED**'}, 'payload': {'exitDelayInSeconds': 0}, 'endpoint': {'scope': {'type': 'BearerToken', 'token': '**REDACTED**'}, 'endpointId': 'alarm_control_panel#spencer_estates', 'cookie': {}}}, 'context': {'properties': [{'name': 'armState', 'namespace': 'Alexa.SecurityPanelController', 'value': 'ARMED_STAY'}, {'name': 'connectivity', 'namespace': 'Alexa.EndpointHealth', 'value': {'value': 'OK'}, 'timeOfSample': '2024-11-02T21:28:40Z', 'uncertaintyInMilliseconds': 0}]}}
2024-11-02 15:28:41.751 DEBUG (MainThread) [homeassistant.components.alexa.state_report] Sent: {"event": {"header": {"namespace": "Alexa", "name": "ChangeReport", "messageId": "c6de4b38-4e3e-4814-8b47-ff895fbaa244", "payloadVersion": "3"}, "payload": {"change": {"cause": {"type": "APP_INTERACTION"}, "properties": [{"name": "armState", "namespace": "Alexa.SecurityPanelController", "value": "ARMED_STAY", "timeOfSample": "2024-11-02T21:28:41Z", "uncertaintyInMilliseconds": 0}, {"name": "connectivity", "namespace": "Alexa.EndpointHealth", "value": {"value": "OK"}, "timeOfSample": "2024-11-02T21:28:41Z", "uncertaintyInMilliseconds": 0}]}}, "endpoint": {"scope": {"type": "BearerToken", "token": "**REDACTED**"}, "endpointId": "alarm_control_panel#spencer_estates"}}}
2024-11-02 15:28:50.966 DEBUG (MainThread) [homeassistant.components.alexa.smart_home] Received Alexa Smart Home request: {'directive': {'header': {'namespace': 'Alexa.SecurityPanelController', 'name': 'Arm', 'payloadVersion': '3', 'messageId': '22c99251-f41e-4520-9c9a-0e00f45138be', 'correlationToken': '**REDACTED**'}, 'endpoint': {'scope': {'type': 'BearerToken', 'token': '**REDACTED**'}, 'endpointId': 'alarm_control_panel#spencer_estates', 'cookie': {}}, 'payload': {'armState': 'ARMED_STAY'}}}
2024-11-02 15:28:50.967 DEBUG (MainThread) [homeassistant.components.alexa.smart_home] Sending Alexa Smart Home response: {'event': {'header': {'namespace': 'Alexa', 'name': 'ErrorResponse', 'messageId': '0865e44b-cc37-47f6-abad-1e162b543900', 'payloadVersion': '3', 'correlationToken': '**REDACTED**'}, 'payload': {'type': 'AUTHORIZATION_REQUIRED', 'message': 'You must disarm the system before you can set the requested arm state.'}, 'endpoint': {'scope': {'type': 'BearerToken', 'token': '**REDACTED**'}, 'endpointId': 'alarm_control_panel#spencer_estates', 'cookie': {}}}}

Additional information

According to the Alexa security panel interface documentation, arming a system with the same status should result in a success, not an error:

"Support the Arm directive so that users can arm their security system. If you receive an Arm directive, and the new armState matches the current armState, respond with a success response, not an error response. However, there are strict requirements for changing armState."

These strict requirements seem to state that the only restriction is you can't change from ARMED_AWAY to a different armed state without first disarming the system.

This would imply that you could, however, go from ARMED_STAY to ARMED_AWAY without first needing to disarm the system.

Thus, it would reason that this check in the code should be adjusted: https://github.com/home-assistant/core/blob/5cf13d92739c8554d386874617e056258fb043c6/homeassistant/components/alexa/handlers.py#L1086-L1088

home-assistant[bot] commented 1 week ago

Hey there @home-assistant/cloud, @ochlocracy, @jbouwh, 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!

Code owner commands Code owners of `alexa` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign alexa` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


alexa documentation alexa source (message by IssueLinks)

jbouwh commented 1 week ago

Okay, do you want to open a PR to fix this yourself?

natekspencer commented 1 week ago

Okay, do you want to open a PR to fix this yourself?

Yeah, I'd be happy to do so!

jbouwh commented 1 week ago

If you open a PR, make sure you add a test case as well that covers the cases that should be successful.