From 05333fc13e0d8e5a24a57543d89f101f533636e6 Mon Sep 17 00:00:00 2001 From: Damien Date: Thu, 28 Nov 2024 16:11:51 +0100 Subject: [PATCH] chore(z2m): move from mqtt topic to device action (#3) --- ..._E2201-E2213_ZHA-Z2M_control-anything.yaml | 212 ++++++++++-------- ikea_E2201-E2213_ZHA-Z2M_control-light.yaml | 161 +++++++------ 2 files changed, 210 insertions(+), 163 deletions(-) diff --git a/ikea_E2201-E2213_ZHA-Z2M_control-anything.yaml b/ikea_E2201-E2213_ZHA-Z2M_control-anything.yaml index bec49ff..274e056 100644 --- a/ikea_E2201-E2213_ZHA-Z2M_control-anything.yaml +++ b/ikea_E2201-E2213_ZHA-Z2M_control-anything.yaml @@ -20,9 +20,9 @@ blueprint: domain: automation input: remote_device: - name: (ZHA) Remote + name: Remote description: > - **_Choose if you are using ZHA._** IKEA remote to use. + IKEA remote (Somrig, Rodret) to use. default: [] selector: device: @@ -33,16 +33,13 @@ blueprint: - integration: zha manufacturer: IKEA of Sweden model: SOMRIG shortcut button + - integration: mqtt + manufacturer: IKEA + model: RODRET wireless dimmer/power switch (E2201) + - integration: mqtt + manufacturer: IKEA + model: SOMRIG shortcut button (E2213) multiple: false - remote_name: - name: (Zigbee2MQTT) Remote Name - description: > - **_Choose if you are using Zigbee2MQTT._** The name of the controller (e.g. IKEA Rodret). - default: [] - base_topic: - name: (Zigbee2MQTT) Base mqtt topic - description: The topic configured in [Z2M addon](https://www.zigbee2mqtt.io/guide/usage/mqtt_topics_and_messages.html). - default: zigbee2mqtt on_press_action: name: Single press action (on / 1 dot) description: Choose action(s) to run when **on** (Rodret) or **1 dot** (Somrig) button is **pressed**. @@ -137,187 +134,206 @@ blueprint: mode: slider mode: single max_exceeded: silent -trigger_variables: - z2m_base_topic: !input base_topic - z2m_controller: !input remote_name - zha_controller: !input remote_device trigger: # RODRET - E2201 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "on" cluster_id: 6 endpoint_id: 1 id: press-on-zha-e2201 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "on" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "on" id: press-on-z2m-e2201 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "off" cluster_id: 6 endpoint_id: 1 id: press-off-zha-e2201 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "off" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "off" id: press-off-z2m-e2201 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "move_with_on_off" cluster_id: 8 endpoint_id: 1 args: [0, 83] id: hold-on-zha-e2201 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "brightness_move_up" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "brightness_move_up" id: hold-on-z2m-e2201 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "move" cluster_id: 8 endpoint_id: 1 args: [1, 83, 0, 0] id: hold-off-zha-e2201 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "brightness_move_down" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "brightness_move_down" id: hold-off-z2m-e2201 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device endpoint_id: 1 cluster_id: 8 command: stop_with_on_off id: release-zha-e2201 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "brightness_stop" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "brightness_stop" id: release-z2m-e2201 # SOMRIG - E2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "short_release" cluster_id: 64640 endpoint_id: 1 args: [0] id: press-dots1-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "1_short_release" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "1_short_release" id: press-dots1-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "short_release" cluster_id: 64640 endpoint_id: 2 args: [0] id: press-dots2-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "2_short_release" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "2_short_release" id: press-dots2-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "multi_press_complete" cluster_id: 64640 endpoint_id: 1 args: [0, 2] id: double-press-dots1-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "1_double_press" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "1_double_press" id: double-press-dots1-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "multi_press_complete" cluster_id: 64640 endpoint_id: 2 args: [0, 2] id: double-press-dots2-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "2_double_press" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "2_double_press" id: double-press-dots2-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "long_press" cluster_id: 64640 endpoint_id: 1 args: [0] id: hold-dots1-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "1_long_press" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "1_long_press" id: hold-dots1-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "long_press" cluster_id: 64640 endpoint_id: 2 args: [0] id: hold-dots2-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "2_long_press" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "2_long_press" id: hold-dots2-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "long_release" cluster_id: 64640 endpoint_id: 1 args: [0] id: release-hold-dots1-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "1_long_release" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "1_long_release" id: release-hold-dots1-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "long_release" cluster_id: 64640 endpoint_id: 2 args: [0] id: release-hold-dots2-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "2_long_release" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "2_long_release" id: release-hold-dots2-z2m-e2213 action: - variables: on_double_press_exposed: !input on_double_press_exposed off_double_press_exposed: !input off_double_press_exposed - zha_controller: !input remote_device - z2m_base_topic: !input base_topic - z2m_controller: !input remote_name - choose: - conditions: - condition: trigger @@ -341,7 +357,7 @@ action: - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "on" cluster_id: 6 endpoint_id: 1 @@ -359,9 +375,11 @@ action: - press-on-z2m-e2201 sequence: - wait_for_trigger: - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "on" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "on" timeout: milliseconds: !input helper_double_press_delay continue_on_timeout: true @@ -394,7 +412,7 @@ action: - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "off" cluster_id: 6 endpoint_id: 1 @@ -412,9 +430,11 @@ action: - press-off-z2m-e2201 sequence: - wait_for_trigger: - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "off" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "off" timeout: milliseconds: !input helper_double_press_delay continue_on_timeout: true @@ -462,7 +482,7 @@ action: - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "stop_with_on_off" cluster_id: 8 endpoint_id: 1 @@ -481,12 +501,16 @@ action: - hold-dots1-z2m-e2213 sequence: - wait_for_trigger: - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "brightness_stop" - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "1_long_release" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "brightness_stop" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "1_long_release" timeout: milliseconds: !input helper_hold_delay continue_on_timeout: true @@ -520,7 +544,7 @@ action: - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "stop_with_on_off" cluster_id: 8 endpoint_id: 1 @@ -539,12 +563,16 @@ action: - hold-dots2-z2m-e2213 sequence: - wait_for_trigger: - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "brightness_stop" - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "2_long_release" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "brightness_stop" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "2_long_release" timeout: milliseconds: !input helper_hold_delay continue_on_timeout: true diff --git a/ikea_E2201-E2213_ZHA-Z2M_control-light.yaml b/ikea_E2201-E2213_ZHA-Z2M_control-light.yaml index b858263..af25a1a 100644 --- a/ikea_E2201-E2213_ZHA-Z2M_control-light.yaml +++ b/ikea_E2201-E2213_ZHA-Z2M_control-light.yaml @@ -35,16 +35,13 @@ blueprint: - integration: zha manufacturer: IKEA of Sweden model: SOMRIG shortcut button + - integration: mqtt + manufacturer: IKEA + model: RODRET wireless dimmer/power switch (E2201) + - integration: mqtt + manufacturer: IKEA + model: SOMRIG shortcut button (E2213) multiple: false - remote_name: - name: (Zigbee2MQTT) Remote Name - description: > - **_Choose if you are using Zigbee2MQTT._** The name of the controller (e.g. IKEA Rodret). - default: "" - base_topic: - name: (Zigbee2MQTT) Base mqtt topic - description: The topic configured in [Z2M addon](https://www.zigbee2mqtt.io/guide/usage/mqtt_topics_and_messages.html). - default: zigbee2mqtt light: name: Light description: Light to control @@ -74,179 +71,201 @@ blueprint: mode: slider mode: restart max_exceeded: silent -trigger_variables: - z2m_base_topic: !input base_topic - z2m_controller: !input remote_name - zha_controller: !input remote_device trigger: # RODRET - E2201 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "on" cluster_id: 6 endpoint_id: 1 id: press-on-zha-e2201 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "on" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "on" id: press-on-z2m-e2201 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "off" cluster_id: 6 endpoint_id: 1 id: press-off-zha-e2201 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "off" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "off" id: press-off-z2m-e2201 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "move_with_on_off" cluster_id: 8 endpoint_id: 1 args: [0, 83] id: hold-on-zha-e2201 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "brightness_move_up" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "brightness_move_up" id: hold-on-z2m-e2201 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "move" cluster_id: 8 endpoint_id: 1 args: [1, 83, 0, 0] id: hold-off-zha-e2201 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "brightness_move_down" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "brightness_move_down" id: hold-off-z2m-e2201 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: stop_with_on_off endpoint_id: 1 cluster_id: 8 id: release-zha-e2201 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "brightness_stop" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "brightness_stop" id: release-z2m-e2201 # SOMRIG - E2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "short_release" cluster_id: 64640 endpoint_id: 1 args: [0] id: press-dots1-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "1_short_release" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "1_short_release" id: press-dots1-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "short_release" cluster_id: 64640 endpoint_id: 2 args: [0] id: press-dots2-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "2_short_release" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "2_short_release" id: press-dots2-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "multi_press_complete" cluster_id: 64640 endpoint_id: 1 args: [0, 2] id: double-press-dots1-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "1_double_press" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "1_double_press" id: double-press-dots1-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "multi_press_complete" cluster_id: 64640 endpoint_id: 2 args: [0, 2] id: double-press-dots2-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "2_double_press" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "2_double_press" id: double-press-dots2-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "long_press" cluster_id: 64640 endpoint_id: 1 args: [0] id: hold-dots1-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "1_long_press" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "1_long_press" id: hold-dots1-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "long_press" cluster_id: 64640 endpoint_id: 2 args: [0] id: hold-dots2-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "2_long_press" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "2_long_press" id: hold-dots2-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "long_release" cluster_id: 64640 endpoint_id: 1 args: [0] id: release-hold-dots1-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "1_long_release" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "1_long_release" id: release-hold-dots1-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: "{{ zha_controller }}" + device_id: !input remote_device command: "long_release" cluster_id: 64640 endpoint_id: 2 args: [0] id: release-hold-dots2-zha-e2213 - - trigger: mqtt - topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}" - payload: "2_long_release" + - trigger: device + domain: mqtt + device_id: !input remote_device + type: action + subtype: "2_long_release" id: release-hold-dots2-z2m-e2213 action: - variables: @@ -266,14 +285,14 @@ action: - choose: - conditions: "{{ helper_force_brightness }}" sequence: - - service: light.turn_on + - action: light.turn_on target: entity_id: !input light data: transition: 1 brightness_pct: !input helper_brightness default: - - service: light.turn_on + - action: light.turn_on target: entity_id: !input light data: @@ -286,7 +305,7 @@ action: - press-dots2-zha-e2213 - press-dots2-z2m-e2213 sequence: - - service: light.turn_off + - action: light.turn_off target: entity_id: !input light data: @@ -309,7 +328,7 @@ action: - hold-dots1-z2m-e2213 sequence: - parallel: - - service: light.turn_on + - action: light.turn_on target: entity_id: !input light data: @@ -331,13 +350,13 @@ action: }}" sequence: - parallel: - - service: light.turn_on + - action: light.turn_on data: brightness_step_pct: "{{ helper_hold_dim_step | int * -1 }}" target: entity_id: !input light - delay: "{{ helper_hold_delay }}" - - service: light.turn_on + - action: light.turn_on data: brightness_pct: 1 target: