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
72.15k stars 30.19k forks source link

Matter Event State Not Comparing Correctly #121402

Closed jvmahon closed 2 months ago

jvmahon commented 3 months ago

The problem

I'm trying to get automations working with the Matter Event entity and the Tuo Smart button but there appears to be an issue detecting the states of the event.

I have the automation set up to detect the Multi Press Complete event which is detected, as expected.

I then test for totalNumberOfPressesCounted and am looking for a "2" for double-pressed. Its a simple test, but it fails.

image

What version of Home Assistant Core has the issue?

2024.7.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Matter

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

alias: Tuo Smart Button 2
description: ""
trigger:
  - platform: state
    entity_id:
      - event.smart_button_button
    attribute: event_type
    to: multi_press_complete
condition:
  - condition: state
    entity_id: event.smart_button_button
    attribute: totalNumberOfPressesCounted
    state: "2"
action:
  - service: light.toggle
    target:
      area_id: office
    data: {}
mode: single

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 3 months ago

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

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


matter documentation matter source (message by IssueLinks)

jvmahon commented 3 months ago

Well, I found the workaround. I manually edited the YAML for the condition and removed the quotes from the "2" value and it worked.

I'd still consider this an issue since the UI should support entering the desired value as a number. I'm assuming that somewhere in the code there's a need for a check that if the "state" is an integer and "wanted_state" is a string, the it may make sense to try and convert the string to an integer.

As a final thought, I'm planning to do a re-write of the event.py handling for buttons so that each button press is represented as a unique attribute ("Button Pressed 1X", "Button Pressed 2X", "Button Pressed 3X", etc.) so the need to detect the event and then do a compare of the state will go away.

marcelveldt commented 2 months ago

Please do not post more issues about the event entity - we are in the process of refactoring this. This is the 3rd issue you reported about this and I keep telling you that we're about to change this logic. Hold your breath and wait a bit, please

marcelveldt commented 2 months ago

@jvmahon FYI I started working on the event entity now - I will ping you when there is something to test / give feedback on.

jvmahon commented 2 months ago

@jvmahon FYI I started working on the event entity now - I will ping you when there is something to test / give feedback on.

Thank you.

marcelveldt commented 2 months ago

This has been addressed with https://github.com/home-assistant/core/pull/122191

jvmahon commented 2 months ago

Is this ready to test, or should I still wait?

That is, can I now install / test the code here: https://github.com/home-assistant/core/tree/dev/homeassistant/components/matter

Thank you.

From: Marcel van der Veldt @.> Sent: Tuesday, July 23, 2024 8:01 AM To: home-assistant/core @.> Cc: jvmahon @.>; Mention @.> Subject: Re: [home-assistant/core] Matter Event State Not Comparing Correctly (Issue #121402)

This has been addressed with #122191https://github.com/home-assistant/core/pull/122191

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/121402#issuecomment-2245041335, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADS5HNVLLPQKU4HSXFUPYKDZNZAWLAVCNFSM6AAAAABKOWZWKKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBVGA2DCMZTGU. You are receiving this because you were mentioned.Message ID: @.**@.>>