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
74.18k stars 31.15k forks source link

Google Assistant: ArmLevel missing #119400

Closed Anto79-ops closed 5 months ago

Anto79-ops commented 5 months ago

The problem

hello,

I noticed the alarm panel on my Google Assistant Hub UI was greyed out (unavaiable) and saw this in my logs:

The log is from 2023.6.2 but, it may have also been there on 2023.6.x as I noticed the alarm panel was also grey-out before 2023.6.2

thanks

Logger: homeassistant.components.google_assistant.smart_home
Source: components/google_assistant/smart_home.py:181
integration: Google Assistant (documentation, issues)
First occurred: 7:16:17 AM (4 occurrences)
Last logged: 7:58:11 AM

Unexpected error serializing query for <state alarm_control_panel.partition1=disarmed; code_format=number, changed_by=None, code_arm_required=False, secure_arm=False, alarm_type=None, last_error_type=None, last_error_desc=None, last_error_at=None, disarm_failed=0, friendly_name=Qolsys Panel partition1, supported_features=63 @ 2024-06-11T07:05:44.936506-06:00>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/smart_home.py", line 181, in async_devices_query_response
    devices[devid] = entity.query_serialize()
                     ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/helpers.py", line 702, in query_serialize
    deep_update(attrs, trt.query_attributes())
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/trait.py", line 1628, in query_attributes
    "currentArmLevel": self._default_arm_state(),
                       ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/trait.py", line 1596, in _default_arm_state
    raise SmartHomeError(ERR_NOT_SUPPORTED, "ArmLevel missing")
homeassistant.components.google_assistant.error.SmartHomeError: ArmLevel missing

the alarm panel works and is it should in HA UI directly.

What version of Home Assistant Core has the issue?

2024.6.2

What was the last working version of Home Assistant Core?

pre 2024.6 (maybe)

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Google Assistant

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 5 months ago

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

Code owner commands Code owners of `google_assistant` 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 google_assistant` 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)


google_assistant documentation google_assistant source (message by IssueLinks)

allenporter commented 5 months ago

This was changed for #115622 -- what states does the alarm control panel support?

This was meant to solve a problem where alarm control panels are not showing up in google home due to missing arm level.

mateusz-lichota commented 5 months ago

Experiencing the exact same issue since 2024.6.2 (2024.6.1 didn't have it). The error was introduced in #119238 - it seems like the method _default_arm_state assumes the default armState will be the first supported state, but the list of states that may be supported doesn't even include "disarmed", so that can't work.

Anto79-ops commented 5 months ago

hello all.

I'd be happy to provided a list of supported states, do you need diagonostics? I'm not sure how to provide a list of this, but definitely disarmed is supported.

mateusz-lichota commented 5 months ago

disarmed is definitely supported in general, but I think the google assistant integration didn't make use of it (see https://github.com/home-assistant/core/pull/119238/files#diff-610fcbdd05a06183431282ef0d29febefc0c5d56166c572cb35e6d6bdf4ef857R1562), since the armLevel wasn't being sent if the alarm was disarmed

elupus commented 5 months ago

When disarmed, it should send the default state that would happen if you arm. So it needs to be another one of the other states supported.

If you look in the developer section on your alarm entity, what states does it list?

elupus commented 5 months ago

Ps. Would be the feature flags of the alarm

Anto79-ops commented 5 months ago

When my alarm panel is armed_home it becomes available in GA.

allenporter commented 5 months ago

@Anto79-ops can you share the state attributes?

Also -- are you able to control the alarm control panel from Googl eHome?

Anto79-ops commented 5 months ago

Hi @allenporter

I just tried to get attributes but there are not any of them, i don't think the integration supports it (via mqtt). The alarm integration is provided by a custom component here.

The alarm system works as it should in HA and has been for over 2 years now. Its only in GA that it recently broke, and get this, its only broken when the system is disarmed state. Soon as I arm the system to say armed_home, the alarm control returns to GA and I can control it normally in HA, but soon as I disarm the system, the alarm cannot be controlled via GA because its offline

see photos of this test:

20240612_080925

20240612_080953

Hope this helps.

allenporter commented 5 months ago

Thanks, can you also include detail about the alarm control panel from home assistant developer tools when in each state? Looking for its state and attributes.

Anto79-ops commented 5 months ago

ok here's the state, i.e. disarmed when its broken in GA

image

I'll have to get you the rest (if you need them)

Sorry for the ping @XaF, if you wanted to chime in on this, that would be great :)

allenporter commented 5 months ago

Thank you -- sorry, but can you also include the same thing when working in Google Home / Nest Hub? appreciate it

allenporter commented 5 months ago

I think the bug is if len(states) != 1: code but should have been len(states) < 1 to check for no arm states.

Anto79-ops commented 5 months ago

sure, here's when its working in GA (armed_home or armed_stay state)

image

elupus commented 5 months ago

I think the bug is if len(states) != 1: code but should have been len(states) < 1 to check for no arm states.

Somewhat like that yes. For some arming only allowed one level to exist for default logic to trigger. I missed that when I extracted the code, and the tests only ever had one level so it never triggered.

So that limit need to removed from the reporting case at least.

elupus commented 5 months ago

I've opened a fix for this issue. It's a "semi" fix/feature change. So i'm not sure if i can include it in a patch release. We'll see.

Anto79-ops commented 5 months ago

Looks like this is fixed on 2024.7.0b0. Thanks

20240626_094650.jpg