Ikea Tradfri Remote Zigbee2mqtt rule

Hi everyone, my issue is different from OH3 IKEA Tradfri remote control with zigbee2mqtt

I want to control multiple lights with this remote. However, when I press one button, all channel from z2m is triggered and all lights are toggled for any button press. How can I resolve this issue?

z2m logs for 1 button press:

info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom', payload '{"action":"brightness_up_click","battery":74,"linkquality":87,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/battery', payload '74'
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/linkquality', payload '87'
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/action', payload 'brightness_up_click'
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update_available', payload ''
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-state', payload ''
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-installed_version', payload '-1'
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-latest_version', payload '-1'
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom', payload '{"action":"","battery":74,"linkquality":87,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/battery', payload '74'
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/linkquality', payload '87'
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/action', payload ''
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update_available', payload ''
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-state', payload ''
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-installed_version', payload '-1'
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-latest_version', payload '-1'
info 2025-07-14 17:51:00z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/action', payload 'brightness_up_click'

z2m logs after 3 button press:

info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom', payload '{"action":"arrow_left_click","battery":74,"linkquality":81,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/battery', payload '74'
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/linkquality', payload '81'
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/action', payload 'arrow_left_click'
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update_available', payload ''
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-state', payload ''
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-installed_version', payload '-1'
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-latest_version', payload '-1'
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom', payload '{"action":"","battery":74,"linkquality":81,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/battery', payload '74'
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/linkquality', payload '81'
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/action', payload ''
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update_available', payload ''
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-state', payload ''
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-installed_version', payload '-1'
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-latest_version', payload '-1'
info 2025-07-14 17:52:03z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/action', payload 'arrow_left_click'
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom', payload '{"action":"brightness_down_click","battery":74,"linkquality":93,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/battery', payload '74'
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/linkquality', payload '93'
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/action', payload 'brightness_down_click'
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update_available', payload ''
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-state', payload ''
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-installed_version', payload '-1'
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-latest_version', payload '-1'
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom', payload '{"action":"","battery":74,"linkquality":93,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/battery', payload '74'
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/linkquality', payload '93'
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/action', payload ''
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update_available', payload ''
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-state', payload ''
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-installed_version', payload '-1'
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-latest_version', payload '-1'
info 2025-07-14 17:52:04z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/action', payload 'brightness_down_click'
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom', payload '{"action":"arrow_right_click","battery":74,"linkquality":81,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/battery', payload '74'
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/linkquality', payload '81'
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/action', payload 'arrow_right_click'
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update_available', payload ''
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-state', payload ''
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-installed_version', payload '-1'
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-latest_version', payload '-1'
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom', payload '{"action":"","battery":74,"linkquality":81,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/battery', payload '74'
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/linkquality', payload '81'
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/action', payload ''
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update_available', payload ''
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-state', payload ''
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-installed_version', payload '-1'
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/update-latest_version', payload '-1'
info 2025-07-14 17:52:06z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Ikea TRADFRI remote Livingroom/action', payload 'arrow_right_click'

3 of my rules from UI:

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Down_Click
    type: core.ItemCommandTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      blockSource: <xml xmlns="https://developers.google.com/blockly/xml"><block
        type="controls_if" id="`uYb|g5^)N_)yhBR`d}h" x="16" y="8"><mutation
        else="1"></mutation><value name="IF0"><block type="logic_compare"
        id="7bqI!-eT6~=(RhZ%1_!~"><field name="OP">EQ</field><value
        name="A"><block type="oh_getitem_state" id="]1gG/_0~GI9SS4f~_d6j"><value
        name="itemName"><shadow type="oh_item"
        id="r+sB*($2d,V(fi;1A,1G"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="LU^v9AP3%Fo(T}ISzP3S"><mutation
        itemName="ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L3"
        itemLabel="Livingroom Back 2 Light"></mutation><field
        name="itemName">ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L3</field></block></value></block></value><value
        name="B"><block type="text" id="m6j|0VhZ[iK6_!aoR^J@"><field
        name="TEXT">ON</field></block></value></block></value><statement
        name="DO0"><block type="oh_event" id=",G4+NazoR0-pvDdX}{AL"><field
        name="eventType">sendCommand</field><value name="value"><shadow
        type="text" id="8e.O1/NXg]vj#AQ%Vwwo"><field
        name="TEXT">value</field></shadow><block type="text"
        id="s,alHd9ln/c.;p!v.~Q5"><field
        name="TEXT">OFF</field></block></value><value name="itemName"><shadow
        type="oh_item" id="EFG3d]Z!VDk~N*|gk?ET"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="AxAI~^9c*M3(iYwL)Y+9"><mutation
        itemName="ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L3"
        itemLabel="Livingroom Back 2 Light"></mutation><field
        name="itemName">ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L3</field></block></value></block></statement><statement
        name="ELSE"><block type="oh_event" id="zHePtCg{S^(2~rF=LH.1"><field
        name="eventType">sendCommand</field><value name="value"><shadow
        type="text" id="8e.O1/NXg]vj#AQ%Vwwo"><field
        name="TEXT">value</field></shadow><block type="text"
        id="4L3[`karULYpn%LE#G{d"><field
        name="TEXT">ON</field></block></value><value name="itemName"><shadow
        type="oh_item" id=":LY~}l15]|@_FdiA:,^%"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="|H]]?zOoFsXHpuEHhSe="><mutation
        itemName="ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L3"
        itemLabel="Livingroom Back 2 Light"></mutation><field
        name="itemName">ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L3</field></block></value></block></statement></block></xml>
      type: application/javascript
      script: >
        if
        (items.getItem('ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L3').state
        == 'ON') {
          items.getItem('ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L3').sendCommand('OFF');
        } else {
          items.getItem('ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L3').sendCommand('ON');
        }
    type: script.ScriptAction


---- NEXT RULE
configuration: {}
triggers:
  - id: "1"
    configuration:
      thingUID: mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42
      channelUID: mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:arrow_left_click
    type: core.ChannelEventTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      blockSource: <xml xmlns="https://developers.google.com/blockly/xml"><block
        type="controls_if" id="`uYb|g5^)N_)yhBR`d}h" x="16" y="8"><mutation
        else="1"></mutation><value name="IF0"><block type="logic_compare"
        id="7bqI!-eT6~=(RhZ%1_!~"><field name="OP">EQ</field><value
        name="A"><block type="oh_getitem_state" id="]1gG/_0~GI9SS4f~_d6j"><value
        name="itemName"><shadow type="oh_item"
        id="r+sB*($2d,V(fi;1A,1G"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="LU^v9AP3%Fo(T}ISzP3S"><mutation
        itemName="ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2"
        itemLabel="Livingroom Back 1 Light"></mutation><field
        name="itemName">ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2</field></block></value></block></value><value
        name="B"><block type="text" id="m6j|0VhZ[iK6_!aoR^J@"><field
        name="TEXT">ON</field></block></value></block></value><statement
        name="DO0"><block type="oh_event" id=",G4+NazoR0-pvDdX}{AL"><field
        name="eventType">sendCommand</field><value name="value"><shadow
        type="text" id="8e.O1/NXg]vj#AQ%Vwwo"><field
        name="TEXT">value</field></shadow><block type="text"
        id="s,alHd9ln/c.;p!v.~Q5"><field
        name="TEXT">OFF</field></block></value><value name="itemName"><shadow
        type="oh_item" id="EFG3d]Z!VDk~N*|gk?ET"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="9u]j(TkBoQxcanJ4AQ]Z"><mutation
        itemName="ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2"
        itemLabel="Livingroom Back 1 Light"></mutation><field
        name="itemName">ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2</field></block></value></block></statement><statement
        name="ELSE"><block type="oh_event" id="zHePtCg{S^(2~rF=LH.1"><field
        name="eventType">sendCommand</field><value name="value"><shadow
        type="text" id="8e.O1/NXg]vj#AQ%Vwwo"><field
        name="TEXT">value</field></shadow><block type="text"
        id="4L3[`karULYpn%LE#G{d"><field
        name="TEXT">ON</field></block></value><value name="itemName"><shadow
        type="oh_item" id="EFG3d]Z!VDk~N*|gk?ET"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="DSc(sv;fF*Je7-(0vmY*"><mutation
        itemName="ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2"
        itemLabel="Livingroom Back 1 Light"></mutation><field
        name="itemName">ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2</field></block></value></block></statement></block></xml>
      type: application/javascript
      script: >
        if
        (items.getItem('ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2').state
        == 'ON') {
          items.getItem('ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2').sendCommand('OFF');
        } else {
          items.getItem('ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2').sendCommand('ON');
        }
    type: script.ScriptAction

--- NEXT RULE
configuration: {}
triggers:
  - id: "1"
    configuration:
      thingUID: mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42
      channelUID: mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:arrow_right_click
    type: core.ChannelEventTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      blockSource: <xml xmlns="https://developers.google.com/blockly/xml"><block
        type="controls_if" id="`uYb|g5^)N_)yhBR`d}h" x="16" y="8"><mutation
        else="1"></mutation><value name="IF0"><block type="logic_compare"
        id="7bqI!-eT6~=(RhZ%1_!~"><field name="OP">EQ</field><value
        name="A"><block type="oh_getitem_state" id="]1gG/_0~GI9SS4f~_d6j"><value
        name="itemName"><shadow type="oh_item"
        id="r+sB*($2d,V(fi;1A,1G"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="LU^v9AP3%Fo(T}ISzP3S"><mutation
        itemName="ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2"
        itemLabel="Livingroom Back 1 Light"></mutation><field
        name="itemName">ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2</field></block></value></block></value><value
        name="B"><block type="text" id="m6j|0VhZ[iK6_!aoR^J@"><field
        name="TEXT">ON</field></block></value></block></value><statement
        name="DO0"><block type="oh_event" id=",G4+NazoR0-pvDdX}{AL"><field
        name="eventType">sendCommand</field><value name="value"><shadow
        type="text" id="8e.O1/NXg]vj#AQ%Vwwo"><field
        name="TEXT">value</field></shadow><block type="text"
        id="s,alHd9ln/c.;p!v.~Q5"><field
        name="TEXT">OFF</field></block></value><value name="itemName"><shadow
        type="oh_item" id="EFG3d]Z!VDk~N*|gk?ET"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="9u]j(TkBoQxcanJ4AQ]Z"><mutation
        itemName="ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2"
        itemLabel="Livingroom Back 1 Light"></mutation><field
        name="itemName">ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2</field></block></value></block></statement><statement
        name="ELSE"><block type="oh_event" id="zHePtCg{S^(2~rF=LH.1"><field
        name="eventType">sendCommand</field><value name="value"><shadow
        type="text" id="8e.O1/NXg]vj#AQ%Vwwo"><field
        name="TEXT">value</field></shadow><block type="text"
        id="4L3[`karULYpn%LE#G{d"><field
        name="TEXT">ON</field></block></value><value name="itemName"><shadow
        type="oh_item" id="EFG3d]Z!VDk~N*|gk?ET"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="DSc(sv;fF*Je7-(0vmY*"><mutation
        itemName="ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2"
        itemLabel="Livingroom Back 1 Light"></mutation><field
        name="itemName">ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2</field></block></value></block></statement></block></xml>
      type: application/javascript
      script: >
        if
        (items.getItem('ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2').state
        == 'ON') {
          items.getItem('ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2').sendCommand('OFF');
        } else {
          items.getItem('ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2').sendCommand('ON');
        }
    type: script.ScriptAction

I tried to change the trigger instead of thing channel event to item event on this rule:

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Up_Click
    type: core.ItemCommandTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      blockSource: <xml xmlns="https://developers.google.com/blockly/xml"><block
        type="controls_if" id="`uYb|g5^)N_)yhBR`d}h" x="16" y="8"><mutation
        else="1"></mutation><value name="IF0"><block type="logic_compare"
        id="7bqI!-eT6~=(RhZ%1_!~"><field name="OP">EQ</field><value
        name="A"><block type="oh_getitem_state" id="]1gG/_0~GI9SS4f~_d6j"><value
        name="itemName"><shadow type="oh_item"
        id="r+sB*($2d,V(fi;1A,1G"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="c7qN.K*.+9c+PIP64=7d"><mutation
        itemName="ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L1"
        itemLabel="Livingroom Middle Light"></mutation><field
        name="itemName">ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L1</field></block></value></block></value><value
        name="B"><block type="text" id="m6j|0VhZ[iK6_!aoR^J@"><field
        name="TEXT">ON</field></block></value></block></value><statement
        name="DO0"><block type="oh_event" id=",G4+NazoR0-pvDdX}{AL"><field
        name="eventType">sendCommand</field><value name="value"><shadow
        type="text" id="8e.O1/NXg]vj#AQ%Vwwo"><field
        name="TEXT">value</field></shadow><block type="text"
        id="s,alHd9ln/c.;p!v.~Q5"><field
        name="TEXT">OFF</field></block></value><value name="itemName"><shadow
        type="oh_item" id="EFG3d]Z!VDk~N*|gk?ET"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="9u]j(TkBoQxcanJ4AQ]Z"><mutation
        itemName="ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L1"
        itemLabel="Livingroom Middle Light"></mutation><field
        name="itemName">ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L1</field></block></value></block></statement><statement
        name="ELSE"><block type="oh_event" id="zHePtCg{S^(2~rF=LH.1"><field
        name="eventType">sendCommand</field><value name="value"><shadow
        type="text" id="8e.O1/NXg]vj#AQ%Vwwo"><field
        name="TEXT">value</field></shadow><block type="text"
        id="4L3[`karULYpn%LE#G{d"><field
        name="TEXT">ON</field></block></value><value name="itemName"><shadow
        type="oh_item" id="EFG3d]Z!VDk~N*|gk?ET"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="^}P5gN;n@^e7J;s#`il{"><mutation
        itemName="ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L1"
        itemLabel="Livingroom Middle Light"></mutation><field
        name="itemName">ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L1</field></block></value></block></statement></block></xml>
      type: application/javascript
      script: >
        if
        (items.getItem('ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L1').state
        == 'ON') {
          items.getItem('ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L1').sendCommand('OFF');
        } else {
          items.getItem('ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L1').sendCommand('ON');
        }
    type: script.ScriptAction

No avail, all triggering every lights.

This is the log from MainUI log viewer after pressing 4 of the ikea remote buttons:

17:57:40.295	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:brightness_up_release triggered
17:57:40.297	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:arrow_right_hold triggered
17:57:40.299	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:arrow_right_release triggered
17:57:40.302	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:brightness_down_click triggered
17:57:40.303	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:brightness_down_hold triggered
17:57:40.305	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:arrow_right_click triggered
17:57:40.306	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:brightness_down_click triggered brightness_down_click
17:57:40.307	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:action#sensor triggered brightness_down_click
17:57:40.309	INFO	openhab.event.ItemCommandEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L3' received command OFF
17:57:40.310	INFO	openhab.event.ItemCommandEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2' received command OFF
17:57:40.311	INFO	openhab.event.ItemCommandEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L3' received command OFF
17:57:40.312	INFO	openhab.event.ItemCommandEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2' received command OFF
17:57:40.314	INFO	openhab.event.ItemStatePredictedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Down_Click' predicted to become brightness_down_click
17:57:40.315	INFO	openhab.event.ItemCommandEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Up_Click' received command
17:57:40.316	INFO	openhab.event.ItemCommandEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Left_Click' received command
17:57:40.318	INFO	openhab.event.ItemCommandEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Down_Click' received command
17:57:40.319	INFO	openhab.event.ItemCommandEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Right_Click' received command
17:57:40.320	INFO	openhab.event.ItemCommandEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Down_Click' received command brightness_down_click
17:57:40.322	INFO	openhab.event.ItemStateChangedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Down_Click' changed from to brightness_down_click
17:57:40.323	INFO	openhab.event.ItemStatePredictedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Up_Click' predicted to become
17:57:40.325	INFO	openhab.event.ItemCommandEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L1' received command OFF
17:57:40.326	INFO	openhab.event.ItemStatePredictedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Left_Click' predicted to become
17:57:40.327	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:action#sensor triggered
17:57:40.328	INFO	openhab.event.ItemStateChangedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Left_Click' changed from arrow_left_click to
17:57:40.330	INFO	openhab.event.ItemStatePredictedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Down_Click' predicted to become
17:57:40.331	INFO	openhab.event.ItemStatePredictedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Right_Click' predicted to become
17:57:40.332	INFO	openhab.event.ItemStateChangedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Down_Click' changed from brightness_down_click to
17:57:40.333	INFO	openhab.event.ItemStatePredictedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Down_Click' predicted to become brightness_down_click
17:57:40.334	INFO	openhab.event.ItemStateChangedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Down_Click' changed from to brightness_down_click
17:57:40.352	INFO	openhab.event.ItemStateChangedEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L3' changed from ON to OFF
17:57:40.428	INFO	openhab.event.ItemStateChangedEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2' changed from ON to OFF
17:57:40.430	INFO	openhab.event.ItemStateChangedEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L1' changed from ON to OFF
17:57:43.581	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:arrow_right_click triggered arrow_right_click
17:57:43.583	INFO	openhab.event.ItemCommandEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Right_Click' received command arrow_right_click
17:57:43.586	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:arrow_left_release triggered
17:57:43.588	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:brightness_down_release triggered
17:57:43.592	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:brightness_up_click triggered
17:57:43.594	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:toggle triggered
17:57:43.597	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:arrow_left_click triggered
17:57:43.599	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:arrow_left_hold triggered
17:57:43.601	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:brightness_up_hold triggered
17:57:43.604	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:brightness_up_release triggered
17:57:43.606	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:arrow_right_hold triggered
17:57:43.608	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:arrow_right_release triggered
17:57:43.610	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:brightness_down_click triggered
17:57:43.613	INFO	openhab.event.ItemStatePredictedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Right_Click' predicted to become arrow_right_click
17:57:43.617	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:brightness_down_hold triggered
17:57:43.620	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:arrow_right_click triggered
17:57:43.623	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:arrow_right_click triggered arrow_right_click
17:57:43.625	INFO	openhab.event.ItemCommandEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Up_Click' received command
17:57:43.628	INFO	openhab.event.ItemCommandEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2' received command ON
17:57:43.630	INFO	openhab.event.ItemCommandEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2' received command ON
17:57:43.632	INFO	openhab.event.ItemCommandEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Left_Click' received command
17:57:43.634	INFO	openhab.event.ItemCommandEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Down_Click' received command
17:57:43.636	INFO	openhab.event.ItemCommandEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Right_Click' received command
17:57:43.637	INFO	openhab.event.ItemCommandEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Right_Click' received command arrow_right_click
17:57:43.640	INFO	openhab.event.ItemStatePredictedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Up_Click' predicted to become
17:57:43.642	INFO	openhab.event.ItemCommandEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L1' received command ON
17:57:43.643	INFO	openhab.event.ItemStateChangedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Right_Click' changed from to arrow_right_click
17:57:43.645	INFO	openhab.event.ItemCommandEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L3' received command ON
17:57:43.647	INFO	openhab.event.ItemCommandEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2' received command ON
17:57:43.649	INFO	openhab.event.ItemStatePredictedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Left_Click' predicted to become
17:57:43.650	INFO	openhab.event.ItemStatePredictedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Down_Click' predicted to become
17:57:43.652	INFO	openhab.event.ItemStatePredictedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Right_Click' predicted to become
17:57:43.654	INFO	openhab.event.ItemStatePredictedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Right_Click' predicted to become arrow_right_click
17:57:43.655	INFO	openhab.event.ItemStateChangedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Down_Click' changed from brightness_down_click to
17:57:43.657	INFO	openhab.event.ItemCommandEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2' received command ON
17:57:43.658	INFO	openhab.event.ItemStateChangedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Right_Click' changed from arrow_right_click to
17:57:43.660	INFO	openhab.event.ItemStateChangedEvent	Item 'Livingroom_Ikea_TRADFRI_remote_MQTT_Device_Trigger_Right_Click' changed from to arrow_right_click
17:57:43.662	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:action#sensor triggered arrow_right_click
17:57:43.663	INFO	openhab.event.ChannelTriggeredEvent	mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42:action#sensor triggered
17:57:43.664	INFO	openhab.event.ItemStateChangedEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L2' changed from OFF to ON
17:57:43.685	INFO	openhab.event.ItemStateChangedEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L1' changed from OFF to ON
17:57:43.731	INFO	openhab.event.ItemStateChangedEvent	Item 'ESPHome_device_livingroomswitch3ch_livingroomswitch3chlocal_1921681154_T3_L3' changed from OFF to ON

Please help to make this remote useful.

This looks reasonable. You get one update when you press the button (brightness_up_click) and then an update when you stop pressing the button (brightness_up_click). In each event, it updates the main topic with the JSON and the sub topics with each individual piece of data.

This also looks reasonable. There are six events, arraow_left_click pressed and then released, brightness_down_click pressed and then released, and finally arrow_right_click and released. In each event, there are nine messages sent to nine different topics, but they are all as described above.

Blockly is one of the few times where screen shots can help.

But what’s really missing here is how the MQTT channels are configured and how they are linked to what Items.

Notice how the same Channel mqtt:homeassistant:23dca9beae:zigbee2mqtt_5F0xb4e3f9fffe4ebd42 gets triggered for every button press. The payload of the triigger event tells you what button was pressed (e.g. brightness_up_release).

There is nothing here to filter the event. So this rule will get triggered every time any button is pressed. You have to tell it which button press you want to trigger the rule for.

image

Noitice the “Event” field that says “Any” by default. You need to put in the event that you want the rule to react to here. For example, “brightness_up_release”. Then the rule will only run for that putton event. If you need the rule to trigger for more than one event, add a separate trigger for each individual event, for example “button_up_click” for one trigger and “button_up_release” for the other.

Thank you! This fixes my issue.

However I don’t really like how OH behaves against this because I already specified which channel should be the trigger.
image
when they already have list of individual channels that should be monitored. Adding new item for each channel and get the rule triggered when the item is updated does not help too.
image

Unfortunately I don’t understand how this channels work, so I don’t have suggestion about it.

But you haven’t specified which button event. There is only one Channel for all the button press events.

With what you’ve shown so far all I can say is there appears to be only one Channel. I don’t know where those other entries in the list come from or if there are indeed more Channels. Maybe there’s a bug there and something that is supposed to work is not working. Based on events.log there is only the one Channel I can see.

I used one of these channels, brightness_up_click, arrow_right_click etc. But I have to specify the payload it received from z2m.
image

:person_shrugging: i don’t use these so all I have to go on is the logs and according to the logs, only one channel is receiving the events and the payload of the event is the button pressed.

Then, TIL that all those events on z2m logs are just one event, repeated for each recognized actions, with empty payloads. Only the first entry is significant.

Yes, that’s what I said above. For each event eight messages get posted to nine different topics. The first one is all the information encoded as JSON and the other eight are each piece of information posted to a separate topic.

But since you are using the HomeAssistant MQTT add-on, all that stuff is handled for you. You’d only need to mess with how the messages are published if you used the Generic MQTT add-on, which is sometimes required as the HA doesn’t always work quite right or support everything you need. In this case it might be that something isn’t quite working right.

Note in OH 5 the HA stuff underwent a massive overhaul. Those separate Channels might work as expected now in OH 5.

1 Like