core: [BUG?] ZHA - Device automation with different args triggers same automation

The problem

I have a quirk (Tuya SmartKnob) with these two device autmation triggers:

    device_automation_triggers = {
        (ROTATED, RIGHT): {
            COMMAND: COMMAND_STEP,
            CLUSTER_ID: 8,
            ENDPOINT_ID: 1,
            ARGS: [0, 13, 1],
        },
        (ROTATED, LEFT): {
            COMMAND: COMMAND_STEP,
            CLUSTER_ID: 8,
            ENDPOINT_ID: 1,
            ARGS: [1, 13, 1],
        },
    }

For rotation right a set up a dimm up automation and for rotate left dimm down. When I rotate right, the automation DimmUp is triggered:

2022-02-07 01:19:47 DEBUG (MainThread) [zigpy_znp.api] Received command: AF.IncomingMsg.Callback(GroupId=0x0000, ClusterId=8, SrcAddr=0xD9D4, SrcEndpoint=1, DstEndpoint=1, WasBroadcast=<Bool.false: 0>, LQI=21, SecurityUse=<Bool.false: 0>, TimeStamp=8705888, TSN=0, Data=b'\x01\x45\x02\x00\x0D\x01\x00', MacSrcAddr=0xD9D4, MsgResultRadius=11)
2022-02-07 01:19:47 DEBUG (MainThread) [zigpy.zcl] [0xd9d4:1:0x0008] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=False disable_default_response=False> manufacturer=None tsn=69 command_id=2>
2022-02-07 01:19:47 DEBUG (MainThread) [zigpy.zcl] [0xd9d4:1:0x0008] ZCL request 0x0002: [0, 13, 1]
2022-02-07 01:19:47 DEBUG (MainThread) [zigpy.zcl] [0xd9d4:1:0x0008] No handler for cluster command 2
2022-02-07 01:19:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event zha_event[L]: device_ieee=54:0f:57:ff:fe:2e:3c:5f, unique_id=54:0f:57:ff:fe:2e:3c:5f:1:0x0008, device_id=3cc97f6cd8c336b5e52a6070f17fd3e8, endpoint_id=1, cluster_id=8, command=step, args=[0, 13, 1]>
2022-02-07 01:19:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event automation_triggered[L]: name=Fabian_SmartKnob_Deckenlicht_DimmUp, entity_id=automation.fabian_smartknob_deckenlicht_dimmup, source=event 'zha_event'>
2022-02-07 01:19:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.fabian_smartknob_deckenlicht_dimmup, old_state=<state automation.fabian_smartknob_deckenlicht_dimmup=on; last_triggered=2022-02-07T01:18:43.108709+01:00, mode=single, current=0, id=1644190324288, friendly_name=Fabian_SmartKnob_Deckenlicht_DimmUp @ 2022-02-07T01:07:58.149267+01:00>, new_state=<state automation.fabian_smartknob_deckenlicht_dimmup=on; last_triggered=2022-02-07T01:19:47.506486+01:00, mode=single, current=1, id=1644190324288, friendly_name=Fabian_SmartKnob_Deckenlicht_DimmUp @ 2022-02-07T01:07:58.149267+01:00>>
2022-02-07 01:19:47 INFO (MainThread) [homeassistant.components.automation.fabian_smartknob_deckenlicht_dimmup] Fabian_SmartKnob_Deckenlicht_DimmUp: Running automation actions
2022-02-07 01:19:47 INFO (MainThread) [homeassistant.components.automation.fabian_smartknob_deckenlicht_dimmup] Fabian_SmartKnob_Deckenlicht_DimmUp: Executing step device automation
2022-02-07 01:19:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=light, service=turn_on, service_data=entity_id=light.fabian_deckenlicht_on_off, brightness_step_pct=10>
2022-02-07 01:19:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.fabian_smartknob_deckenlicht_dimmup, old_state=<state automation.fabian_smartknob_deckenlicht_dimmup=on; last_triggered=2022-02-07T01:19:47.506486+01:00, mode=single, current=1, id=1644190324288, friendly_name=Fabian_SmartKnob_Deckenlicht_DimmUp @ 2022-02-07T01:07:58.149267+01:00>, new_state=<state automation.fabian_smartknob_deckenlicht_dimmup=on; last_triggered=2022-02-07T01:19:47.506486+01:00, mode=single, current=0, id=1644190324288, friendly_name=Fabian_SmartKnob_Deckenlicht_DimmUp @ 2022-02-07T01:07:58.149267+01:00>>
2022-02-07 01:19:48 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=light.fabian_deckenlicht_on_off, old_state=<state light.fabian_deckenlicht_on_off=on; min_mireds=153, max_mireds=370, supported_color_modes=['brightness', 'color_temp'], color_mode=color_temp, brightness=26, color_temp=212, hs_color=(26.792, 23.244), rgb_color=(255, 222, 195), xy_color=(0.384, 0.354), friendly_name=On/Off, supported_features=32 @ 2022-02-07T01:07:51.562526+01:00>, new_state=<state light.fabian_deckenlicht_on_off=on; min_mireds=153, max_mireds=370, supported_color_modes=['brightness', 'color_temp'], color_mode=color_temp, brightness=51, color_temp=212, hs_color=(26.792, 23.244), rgb_color=(255, 222, 195), xy_color=(0.384, 0.354), friendly_name=On/Off, supported_features=32 @ 2022-02-07T01:07:51.562526+01:00>>
2022-02-07 01:19:48 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.fabian_deckenlicht_current_consumption, old_state=<state sensor.fabian_deckenlicht_current_consumption=1.8; state_class=measurement, unit_of_measurement=W, device_class=power, friendly_name=Aktueller Verbrauch @ 2022-02-07T01:18:43.651344+01:00>, new_state=<state sensor.fabian_deckenlicht_current_consumption=2.8; state_class=measurement, unit_of_measurement=W, device_class=power, friendly_name=Aktueller Verbrauch @ 2022-02-07T01:19:48.059870+01:00>>

But when I rotate left, first the automation DimmUp is called and then DimmDown:

22-02-07 01:18:43 DEBUG (MainThread) [zigpy_znp.api] Received command: AF.IncomingMsg.Callback(GroupId=0x0000, ClusterId=8, SrcAddr=0xD9D4, SrcEndpoint=1, DstEndpoint=1, WasBroadcast=<Bool.false: 0>, LQI=14, SecurityUse=<Bool.false: 0>, TimeStamp=4680024, TSN=0, Data=b'\x01\x44\x02\x01\x0D\x01\x00', MacSrcAddr=0xD9D4, MsgResultRadius=11)
2022-02-07 01:18:43 DEBUG (MainThread) [zigpy.zcl] [0xd9d4:1:0x0008] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=False disable_default_response=False> manufacturer=None tsn=68 command_id=2>
2022-02-07 01:18:43 DEBUG (MainThread) [zigpy.zcl] [0xd9d4:1:0x0008] ZCL request 0x0002: [1, 13, 1]
2022-02-07 01:18:43 DEBUG (MainThread) [zigpy.zcl] [0xd9d4:1:0x0008] No handler for cluster command 2
2022-02-07 01:18:43 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event zha_event[L]: device_ieee=54:0f:57:ff:fe:2e:3c:5f, unique_id=54:0f:57:ff:fe:2e:3c:5f:1:0x0008, device_id=3cc97f6cd8c336b5e52a6070f17fd3e8, endpoint_id=1, cluster_id=8, command=step, args=[1, 13, 1]>
2022-02-07 01:18:43 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event automation_triggered[L]: name=Fabian_SmartKnob_Deckenlicht_DimmUp, entity_id=automation.fabian_smartknob_deckenlicht_dimmup, source=event 'zha_event'>
2022-02-07 01:18:43 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.fabian_smartknob_deckenlicht_dimmup, old_state=<state automation.fabian_smartknob_deckenlicht_dimmup=on; last_triggered=2022-02-07T01:18:27.482595+01:00, mode=single, current=0, id=1644190324288, friendly_name=Fabian_SmartKnob_Deckenlicht_DimmUp @ 2022-02-07T01:07:58.149267+01:00>, new_state=<state automation.fabian_smartknob_deckenlicht_dimmup=on; last_triggered=2022-02-07T01:18:43.108709+01:00, mode=single, current=1, id=1644190324288, friendly_name=Fabian_SmartKnob_Deckenlicht_DimmUp @ 2022-02-07T01:07:58.149267+01:00>>
2022-02-07 01:18:43 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event automation_triggered[L]: name=Fabian_SmartKnob_Deckenlicht_DimmDown, entity_id=automation.fabian_smartknob_deckenlicht_dimmdown, source=event 'zha_event'>
2022-02-07 01:18:43 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.fabian_smartknob_deckenlicht_dimmdown, old_state=<state automation.fabian_smartknob_deckenlicht_dimmdown=on; last_triggered=2022-02-07T01:18:27.483887+01:00, mode=single, current=0, id=1644190345512, friendly_name=Fabian_SmartKnob_Deckenlicht_DimmDown @ 2022-02-07T01:08:04.202702+01:00>, new_state=<state automation.fabian_smartknob_deckenlicht_dimmdown=on; last_triggered=2022-02-07T01:18:43.110139+01:00, mode=single, current=1, id=1644190345512, friendly_name=Fabian_SmartKnob_Deckenlicht_DimmDown @ 2022-02-07T01:08:04.202702+01:00>>
2022-02-07 01:18:43 INFO (MainThread) [homeassistant.components.automation.fabian_smartknob_deckenlicht_dimmup] Fabian_SmartKnob_Deckenlicht_DimmUp: Running automation actions
2022-02-07 01:18:43 INFO (MainThread) [homeassistant.components.automation.fabian_smartknob_deckenlicht_dimmup] Fabian_SmartKnob_Deckenlicht_DimmUp: Executing step device automation
2022-02-07 01:18:43 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=light, service=turn_on, service_data=entity_id=light.fabian_deckenlicht_on_off, brightness_step_pct=10>
2022-02-07 01:18:43 INFO (MainThread) [homeassistant.components.automation.fabian_smartknob_deckenlicht_dimmdown] Fabian_SmartKnob_Deckenlicht_DimmDown: Running automation actions
2022-02-07 01:18:43 INFO (MainThread) [homeassistant.components.automation.fabian_smartknob_deckenlicht_dimmdown] Fabian_SmartKnob_Deckenlicht_DimmDown: Executing step device automation
2022-02-07 01:18:43 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=light, service=turn_on, service_data=entity_id=light.fabian_deckenlicht_on_off, brightness_step_pct=-10>
2022-02-07 01:18:43 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.fabian_smartknob_deckenlicht_dimmup, old_state=<state automation.fabian_smartknob_deckenlicht_dimmup=on; last_triggered=2022-02-07T01:18:43.108709+01:00, mode=single, current=1, id=1644190324288, friendly_name=Fabian_SmartKnob_Deckenlicht_DimmUp @ 2022-02-07T01:07:58.149267+01:00>, new_state=<state automation.fabian_smartknob_deckenlicht_dimmup=on; last_triggered=2022-02-07T01:18:43.108709+01:00, mode=single, current=0, id=1644190324288, friendly_name=Fabian_SmartKnob_Deckenlicht_DimmUp @ 2022-02-07T01:07:58.149267+01:00>>
2022-02-07 01:18:43 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.fabian_smartknob_deckenlicht_dimmdown, old_state=<state automation.fabian_smartknob_deckenlicht_dimmdown=on; last_triggered=2022-02-07T01:18:43.110139+01:00, mode=single, current=1, id=1644190345512, friendly_name=Fabian_SmartKnob_Deckenlicht_DimmDown @ 2022-02-07T01:08:04.202702+01:00>, new_state=<state automation.fabian_smartknob_deckenlicht_dimmdown=on; last_triggered=2022-02-07T01:18:43.110139+01:00, mode=single, current=0, id=1644190345512, friendly_name=Fabian_SmartKnob_Deckenlicht_DimmDown @ 2022-02-07T01:08:04.202702+01:00>>
2022-02-07 01:18:43 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=light.fabian_deckenlicht_on_off, old_state=<state light.fabian_deckenlicht_on_off=on; min_mireds=153, max_mireds=370, supported_color_modes=['brightness', 'color_temp'], color_mode=color_temp, brightness=51, color_temp=212, hs_color=(26.792, 23.244), rgb_color=(255, 222, 195), xy_color=(0.384, 0.354), friendly_name=On/Off, supported_features=32 @ 2022-02-07T01:07:51.562526+01:00>, new_state=<state light.fabian_deckenlicht_on_off=on; min_mireds=153, max_mireds=370, supported_color_modes=['brightness', 'color_temp'], color_mode=color_temp, brightness=26, color_temp=212, hs_color=(26.792, 23.244), rgb_color=(255, 222, 195), xy_color=(0.384, 0.354), friendly_name=On/Off, supported_features=32 @ 2022-02-07T01:07:51.562526+01:00>>
2022-02-07 01:18:43 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.fabian_deckenlicht_current_consumption, old_state=<state sensor.fabian_deckenlicht_current_consumption=2.8; state_class=measurement, unit_of_measurement=W, device_class=power, friendly_name=Aktueller Verbrauch @ 2022-02-07T01:18:27.935860+01:00>, new_state=<state sensor.fabian_deckenlicht_current_consumption=1.8; state_class=measurement, unit_of_measurement=W, device_class=power, friendly_name=Aktueller Verbrauch @ 2022-02-07T01:18:43.651344+01:00>>

What version of Home Assistant Core has the issue?

core-2022.2.2

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

ZHA

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

- id: '1644190324288'
  alias: Fabian_SmartKnob_Deckenlicht_DimmUp
  description: ''
  trigger:
  - device_id: 3cc97f6cd8c336b5e52a6070f17fd3e8
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: right
  condition: []
  action:
  - device_id: ded8c256a221c111531ecce08e8ddeb9
    domain: light
    entity_id: light.fabian_deckenlicht_on_off
    type: brightness_increase
  mode: single
- id: '1644190345512'
  alias: Fabian_SmartKnob_Deckenlicht_DimmDown
  description: ''
  trigger:
  - device_id: 3cc97f6cd8c336b5e52a6070f17fd3e8
    domain: zha
    platform: device
    type: device_rotated
    subtype: left
  condition: []
  action:
  - device_id: ded8c256a221c111531ecce08e8ddeb9
    domain: light
    entity_id: light.fabian_deckenlicht_on_off
    type: brightness_decrease
  mode: single

Anything in the logs that might be useful for us?

No response

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 27 (20 by maintainers)

Most upvoted comments

I think it is a bug in HA core and particularly in the way voluptuous is processing lists. IIRC voluptuous matches the list or ignores elements with 0. In other words a trigger condition [0, 1, 255] would match input lists [0, 1, 255] and [1, 1, 255]

There was something similar reported long time ago. I wasn’t able to find the report.

I didn’t test it. currently I don’t have much time but I can test it monday/tuesday.

Like this made from device cad:

alias: Single
description: ''
trigger:
  - device_id: cf4d64a8db61e2dd336a30f6ae769553
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: button_1
condition: []
action:
  - event: zha_event
    event_data:
      Button: Single pressed
mode: single

I was deleting all test automatons (around 50) and making 3 new ones and its not working so very likely i have / was using the wrong DA then testing in the automation and using the button press for command mode in the automation for event mode.

So in the end all T004F device classes is tested and looks working OK.

Thanks for support !!

What am I missing in the RK example? The command is different in each and it is part of the trigger definition. Args and Params aren’t even used in the trigger definitions so they can’t impact this case at all

@Tropaion Looks like the updated quirk and Zigpy is making it working then using PARMS instead of AEGS 😃)

The bad side is that the long press and release have stop working 😦((( The Dimmer switch is sending the same commands on all 4 end point and have the same DA and working.

RK DA and events:

        (SHORT_PRESS, BUTTON_1): {ENDPOINT_ID: 1, COMMAND: SHORT_PRESS}, OK
        (LONG_PRESS, BUTTON_1): {ENDPOINT_ID: 1, COMMAND: LONG_PRESS}, Not working
        (DOUBLE_PRESS, BUTTON_1): {ENDPOINT_ID: 1, COMMAND: DOUBLE_PRESS}, Not working

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:3c:84:ff:fe:b1:5b:b3",
        "unique_id": "00:3c:84:ff:fe:b1:5b:b3:1:0x0006",
        "device_id": "cf4d64a8db61e2dd336a30f6ae769553",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "remote_button_short_press",
        "args": [],
        "params": {}
    },

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:3c:84:ff:fe:b1:5b:b3",
        "unique_id": "00:3c:84:ff:fe:b1:5b:b3:1:0x0006",
        "device_id": "cf4d64a8db61e2dd336a30f6ae769553",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "remote_button_long_press",
        "args": [],
        "params": {}
    },

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:3c:84:ff:fe:b1:5b:b3",
        "unique_id": "00:3c:84:ff:fe:b1:5b:b3:1:0x0006",
        "device_id": "cf4d64a8db61e2dd336a30f6ae769553",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "remote_button_double_press",
        "args": [],
        "params": {}
    },

DS DA and events:

        (SHORT_PRESS, BUTTON_1): {ENDPOINT_ID: 1, COMMAND: SHORT_PRESS}, OK
        (LONG_PRESS, BUTTON_1): {ENDPOINT_ID: 1, COMMAND: LONG_PRESS}, OK
        (DOUBLE_PRESS, BUTTON_1): {ENDPOINT_ID: 1, COMMAND: DOUBLE_PRESS}, OK


{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "60:a4:23:ff:fe:fd:dc:14",
        "unique_id": "60:a4:23:ff:fe:fd:dc:14:1:0x0006",
        "device_id": "f0aca6ce4c51450cf16577d5d2d4e4b4",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "remote_button_short_press",
        "args": [],
        "params": {}
    }, 



    "event_type": "zha_event",
    "data": {
        "device_ieee": "60:a4:23:ff:fe:fd:dc:14",
        "unique_id": "60:a4:23:ff:fe:fd:dc:14:1:0x0006",
        "device_id": "f0aca6ce4c51450cf16577d5d2d4e4b4",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "remote_button_long_press",
        "args": [],
        "params": {}
    },

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "60:a4:23:ff:fe:fd:dc:14",
        "unique_id": "60:a4:23:ff:fe:fd:dc:14:1:0x0006",
        "device_id": "f0aca6ce4c51450cf16577d5d2d4e4b4",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "remote_button_double_press",
        "args": [],
        "params": {}
    },

@Adminiuga Is the bug already known or should we open a issue for it?

Yeah sorry, posted it wrongly, I do have it like that, but still doesn’t work.

- id: '1644190324288'
  alias: Fabian_SmartKnob_Deckenlicht_DimmUp
  description: ''
  trigger:
  - device_id: 3cc97f6cd8c336b5e52a6070f17fd3e8
    domain: zha
    platform: device
    type: device_rotated
    subtype: right
  condition: []
  action:
  - device_id: ded8c256a221c111531ecce08e8ddeb9
    domain: light
    entity_id: light.fabian_deckenlicht_on_off
    type: brightness_increase
  mode: single
- id: '1644190345512'
  alias: Fabian_SmartKnob_Deckenlicht_DimmDown
  description: ''
  trigger:
  - device_id: 3cc97f6cd8c336b5e52a6070f17fd3e8
    domain: zha
    platform: device
    type: device_rotated
    subtype: left
  condition: []
  action:
  - device_id: ded8c256a221c111531ecce08e8ddeb9
    domain: light
    entity_id: light.fabian_deckenlicht_on_off
    type: brightness_decrease
  mode: single