From 02935e6ad63dd79c8175947edeb3ce9e11320899 Mon Sep 17 00:00:00 2001 From: Damien Date: Wed, 5 Feb 2025 09:57:52 +0100 Subject: [PATCH] feat: allow multiple remotes (#17) * feat!: allow multiple remotes * doc: add fancy emojis * fix: press-dots2-z2m-e2213 * chore: add PR labeling and changelog template --- .github/release.yaml | 21 ++ .github/workflows/conventional-label.yaml | 9 + ...-E2201-E2213_ZHA-Z2M_control-anything.yaml | 228 ++++++++---------- ...743-E2201-E2213_ZHA-Z2M_control-light.yaml | 177 +++++--------- 4 files changed, 188 insertions(+), 247 deletions(-) create mode 100644 .github/release.yaml create mode 100644 .github/workflows/conventional-label.yaml diff --git a/.github/release.yaml b/.github/release.yaml new file mode 100644 index 0000000..1f60f05 --- /dev/null +++ b/.github/release.yaml @@ -0,0 +1,21 @@ +changelog: + exclude: + labels: + - ignore-for-release + categories: + - title: 💥 Breaking Changes + labels: + - breaking + - title: 🚀 Features + labels: + - feature + - title: 🛠️ Fixes + labels: + - bug + - fix + - title: 📓 Documentation + labels: + - doc + - title: ⚙️ Other Changes + labels: + - "*" \ No newline at end of file diff --git a/.github/workflows/conventional-label.yaml b/.github/workflows/conventional-label.yaml new file mode 100644 index 0000000..bd97805 --- /dev/null +++ b/.github/workflows/conventional-label.yaml @@ -0,0 +1,9 @@ +on: + pull_request_target: + types: [ opened, edited ] +name: conventional-release-labels +jobs: + label: + runs-on: ubuntu-latest + steps: + - uses: bcoe/conventional-release-labels@v1 \ No newline at end of file diff --git a/ikea_E1743-E2201-E2213_ZHA-Z2M_control-anything.yaml b/ikea_E1743-E2201-E2213_ZHA-Z2M_control-anything.yaml index e6a7462..063a1cb 100644 --- a/ikea_E1743-E2201-E2213_ZHA-Z2M_control-anything.yaml +++ b/ikea_E1743-E2201-E2213_ZHA-Z2M_control-anything.yaml @@ -3,9 +3,9 @@ blueprint: min_version: 2024.10.0 author: damru domain: automation - name: IKEA Tradfri on/off (E1743), IKEA Rodret (E2201) or IKEA Somrig (E2213) Controls (ZHA/Z2M) + name: Ikea's Tradfri, Rodret or Somrig ⚙️ Controls description: > - ## Control anything with **IKEA TRADFRI ON/OFF** or **IKEA RODRET** or **IKEA SOMRIG** remotes + ## ⚙️ Control anything with **IKEA TRADFRI ON/OFF** or **IKEA RODRET** or **IKEA SOMRIG** remotes Only for use with [ZHA](https://www.home-assistant.io/integrations/zha/) @@ -22,8 +22,8 @@ blueprint: - Hold **on/off** (Tradfri, Rodret) **1 dot/2 dots** (Somrig). Actions will be executed every **Hold delay**, but maximum **Max number of loops** times. input: - remote_device: - name: Remote + remote_devices: + name: Remotes description: > IKEA remote (Tradfri, Rodret, Somrig) to use. default: [] @@ -60,7 +60,7 @@ blueprint: - integration: mqtt manufacturer: IKEA model: SOMRIG shortcut button (E2213) - multiple: false + multiple: true on_press_action: name: Press "on / 1 dot" action description: Choose action(s) to run when **on** (Tradfri, Rodret) or **1 dot** (Somrig) button is **pressed**. @@ -168,189 +168,161 @@ blueprint: mode: single max_exceeded: silent triggers: - # TRADFRI - E1743 + RODRET - E2201 + # TRADFRI (E1743) + RODRET (E2201) - trigger: event event_type: zha_event event_data: - device_id: !input remote_device command: "on" cluster_id: 6 endpoint_id: 1 id: press-on-zha-e1743-e2201 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "on" + - trigger: mqtt + topic: "+/+/action" + payload: "on" id: press-on-z2m-e1743-e2201 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device command: "off" cluster_id: 6 endpoint_id: 1 id: press-off-zha-e1743-e2201 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "off" + - trigger: mqtt + topic: "+/+/action" + payload: "off" id: press-off-z2m-e1743-e2201 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "move_with_on_off" + command: move_with_on_off cluster_id: 8 endpoint_id: 1 - args: [0, 83] id: hold-on-zha-e1743-e2201 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "brightness_move_up" + - trigger: mqtt + topic: "+/+/action" + payload: brightness_move_up id: hold-on-z2m-e1743-e2201 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "move" + command: move cluster_id: 8 endpoint_id: 1 - args: [1, 83, 0, 0] id: hold-off-zha-e1743-e2201 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "brightness_move_down" + - trigger: mqtt + topic: "+/+/action" + payload: brightness_move_down id: hold-off-z2m-e1743-e2201 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device endpoint_id: 1 cluster_id: 8 command: stop_with_on_off id: release-zha-e1743-e2201 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "brightness_stop" + - trigger: mqtt + topic: "+/+/action" + payload: brightness_stop id: release-z2m-e1743-e2201 - # SOMRIG - E2213 + # SOMRIG (E2213) - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "short_release" + command: short_release endpoint_id: 1 id: press-dots1-zha-e2213 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "1_short_release" + - trigger: mqtt + topic: "+/+/action" + payload: 1_short_release id: press-dots1-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "short_release" + command: short_release endpoint_id: 2 id: press-dots2-zha-e2213 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "2_short_release" + - trigger: mqtt + topic: "+/+/action" + payload: 2_short_release id: press-dots2-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "multi_press_complete" + command: multi_press_complete endpoint_id: 1 id: double-press-dots1-zha-e2213 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "1_double_press" + - trigger: mqtt + topic: "+/+/action" + payload: 1_double_press id: double-press-dots1-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "multi_press_complete" + command: multi_press_complete endpoint_id: 2 id: double-press-dots2-zha-e2213 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "2_double_press" + - trigger: mqtt + topic: "+/+/action" + payload: 2_double_press id: double-press-dots2-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "long_press" + command: long_press endpoint_id: 1 id: hold-dots1-zha-e2213 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "1_long_press" + - trigger: mqtt + topic: "+/+/action" + payload: 1_long_press id: hold-dots1-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "long_press" + command: long_press endpoint_id: 2 id: hold-dots2-zha-e2213 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "2_long_press" + - trigger: mqtt + topic: "+/+/action" + payload: 2_long_press id: hold-dots2-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "long_release" + command: long_release endpoint_id: 1 id: release-hold-dots1-zha-e2213 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "1_long_release" + - trigger: mqtt + topic: "+/+/action" + payload: 1_long_release id: release-hold-dots1-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "long_release" + command: long_release endpoint_id: 2 id: release-hold-dots2-zha-e2213 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "2_long_release" + - trigger: mqtt + topic: "+/+/action" + payload: 2_long_release id: release-hold-dots2-z2m-e2213 +variables: + on_double_press_exposed: !input on_double_press_exposed + off_double_press_exposed: !input off_double_press_exposed + remote_devices: !input remote_devices + remote_device: >- + {% set is_zha = trigger.platform == "zha_event" %} + {% set is_mqtt = trigger.platform == "mqtt" %} + {% set device_name = trigger.topic.split("/")[1] if is_mqtt else none %} + {{ + (trigger.event.data.device_id if is_zha) or + (device_id(trigger.topic.split("/")[1]) if is_mqtt and device_name) + }} + mqtt_topic: "{{ trigger.topic }}" +condition: + - condition: template + value_template: "{{ remote_device in remote_devices }}" actions: - - variables: - on_double_press_exposed: !input on_double_press_exposed - off_double_press_exposed: !input off_double_press_exposed - choose: - conditions: - condition: trigger @@ -374,7 +346,7 @@ actions: - trigger: event event_type: zha_event event_data: - device_id: !input remote_device + device_id: "{{ remote_device }}" command: "on" cluster_id: 6 endpoint_id: 1 @@ -392,11 +364,9 @@ actions: - press-on-z2m-e1743-e2201 sequence: - wait_for_trigger: - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "on" + - trigger: mqtt + topic: "{{ mqtt_topic }}" + payload: "on" timeout: milliseconds: !input helper_double_press_delay continue_on_timeout: true @@ -429,7 +399,7 @@ actions: - trigger: event event_type: zha_event event_data: - device_id: !input remote_device + device_id: "{{ remote_device }}" command: "off" cluster_id: 6 endpoint_id: 1 @@ -447,11 +417,9 @@ actions: - press-off-z2m-e1743-e2201 sequence: - wait_for_trigger: - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "off" + - trigger: mqtt + topic: "{{ mqtt_topic }}" + payload: "off" timeout: milliseconds: !input helper_double_press_delay continue_on_timeout: true @@ -501,7 +469,7 @@ actions: - trigger: event event_type: zha_event event_data: - device_id: !input remote_device + device_id: "{{ remote_device }}" command: "stop_with_on_off" cluster_id: 8 endpoint_id: 1 @@ -520,16 +488,12 @@ actions: - hold-dots1-z2m-e2213 sequence: - wait_for_trigger: - - 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" + - trigger: mqtt + topic: "{{ mqtt_topic }}" + payload: "brightness_stop" + - trigger: mqtt + topic: "{{ mqtt_topic }}" + payload: "1_long_release" timeout: milliseconds: !input helper_hold_delay continue_on_timeout: true @@ -563,7 +527,7 @@ actions: - trigger: event event_type: zha_event event_data: - device_id: !input remote_device + device_id: "{{ remote_device }}" command: "stop_with_on_off" cluster_id: 8 endpoint_id: 1 @@ -582,16 +546,12 @@ actions: - hold-dots2-z2m-e2213 sequence: - wait_for_trigger: - - 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" + - trigger: mqtt + topic: "{{ mqtt_topic }}" + payload: "brightness_stop" + - trigger: mqtt + topic: "{{ mqtt_topic }}" + payload: "2_long_release" timeout: milliseconds: !input helper_hold_delay continue_on_timeout: true diff --git a/ikea_E1743-E2201-E2213_ZHA-Z2M_control-light.yaml b/ikea_E1743-E2201-E2213_ZHA-Z2M_control-light.yaml index ac7e19d..0fef1c8 100644 --- a/ikea_E1743-E2201-E2213_ZHA-Z2M_control-light.yaml +++ b/ikea_E1743-E2201-E2213_ZHA-Z2M_control-light.yaml @@ -3,9 +3,9 @@ blueprint: min_version: 2024.10.0 author: damru domain: automation - name: IKEA Tradfri (E1743) or IKEA Rodret (E2201) or IKEA Somrig (E2213) Light control (ZHA/Z2M) + name: Ikea's Tradfri, Rodret or Somrig 💡 Light control description: > - ## Control a light with **IKEA TRADFRI ON/OFF** or **IKEA RODRET** or **IKEA SOMRIG** remotes + ## 💡 Control a light with **IKEA TRADFRI ON/OFF** or ***IKEA RODRET** or **IKEA SOMRIG** remotes Only for use with [ZHA](https://www.home-assistant.io/integrations/zha/) @@ -24,8 +24,8 @@ blueprint: - Hold **off** (Tradfri, Rodret) or **2 dots** (Somrig) button to decrease the brightness down to 1% input: - remote_device: - name: Remote + remote_devices: + name: Remotes description: > IKEA remote (Tradfri, Rodret, Somrig) to use. default: "" @@ -62,7 +62,7 @@ blueprint: - integration: mqtt manufacturer: IKEA model: SOMRIG shortcut button (E2213) - multiple: false + multiple: true light: name: Light description: Light to control @@ -102,187 +102,138 @@ triggers: - trigger: event event_type: zha_event event_data: - device_id: !input remote_device command: "on" cluster_id: 6 endpoint_id: 1 id: press-on-zha-e1743-e2201 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "on" + - trigger: mqtt + topic: "+/+/action" + payload: "on" id: press-on-z2m-e1743-e2201 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device command: "off" cluster_id: 6 endpoint_id: 1 id: press-off-zha-e1743-e2201 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "off" + - trigger: mqtt + topic: "+/+/action" + payload: "off" id: press-off-z2m-e1743-e2201 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "move_with_on_off" + command: move_with_on_off cluster_id: 8 endpoint_id: 1 - args: [0, 83] id: hold-on-zha-e1743-e2201 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "brightness_move_up" + - trigger: mqtt + topic: "+/+/action" + payload: brightness_move_up id: hold-on-z2m-e1743-e2201 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "move" + command: move cluster_id: 8 endpoint_id: 1 - args: [1, 83, 0, 0] id: hold-off-zha-e1743-e2201 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "brightness_move_down" + - trigger: mqtt + topic: "+/+/action" + payload: brightness_move_down id: hold-off-z2m-e1743-e2201 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: stop_with_on_off endpoint_id: 1 cluster_id: 8 id: release-zha-e1743-e2201 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "brightness_stop" + - trigger: mqtt + topic: "+/+/action" + payload: brightness_stop id: release-z2m-e1743-e2201 # SOMRIG - E2213 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "short_release" + command: short_release endpoint_id: 1 id: press-dots1-zha-e2213 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "1_short_release" + - trigger: mqtt + topic: "+/+/action" + payload: 1_short_release id: press-dots1-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "short_release" + command: short_release endpoint_id: 2 id: press-dots2-zha-e2213 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "2_short_release" + - trigger: mqtt + topic: "+/+/action" + payload: 2_short_release id: press-dots2-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "multi_press_complete" - endpoint_id: 1 - id: double-press-dots1-zha-e2213 - - 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: !input remote_device - command: "multi_press_complete" - endpoint_id: 2 - id: double-press-dots2-zha-e2213 - - 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: !input remote_device - command: "long_press" + command: long_press endpoint_id: 1 id: hold-dots1-zha-e2213 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "1_long_press" + - trigger: mqtt + topic: "+/+/action" + payload: 1_long_press id: hold-dots1-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "long_press" + command: long_press endpoint_id: 2 id: hold-dots2-zha-e2213 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "2_long_press" + - trigger: mqtt + topic: "+/+/action" + payload: 2_long_press id: hold-dots2-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "long_release" + command: long_release endpoint_id: 1 id: release-hold-dots1-zha-e2213 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "1_long_release" + - trigger: mqtt + topic: "+/+/action" + payload: 1_long_release id: release-hold-dots1-z2m-e2213 - trigger: event event_type: zha_event event_data: - device_id: !input remote_device - command: "long_release" + command: long_release endpoint_id: 2 id: release-hold-dots2-zha-e2213 - - trigger: device - domain: mqtt - device_id: !input remote_device - type: action - subtype: "2_long_release" + - trigger: mqtt + topic: "+/+/action" + payload: 2_long_release id: release-hold-dots2-z2m-e2213 +variables: + helper_force_brightness: !input helper_force_brightness + helper_hold_delay: 0.1 + helper_hold_dim_step: 4 + light: !input light + remote_devices: !input remote_devices + remote_device: >- + {% set is_zha = trigger.platform == "zha_event" %} + {% set is_mqtt = trigger.platform == "mqtt" %} + {% set device_name = trigger.topic.split("/")[1] if is_mqtt else none %} + {{ + (trigger.event.data.device_id if is_zha) or + (device_id(trigger.topic.split("/")[1]) if is_mqtt and device_name) + }} + mqtt_topic: "{{ trigger.topic }}" +condition: + - condition: template + value_template: "{{ remote_device in remote_devices }}" actions: - - variables: - helper_force_brightness: !input helper_force_brightness - helper_hold_delay: 0.1 - helper_hold_dim_step: 4 - light: !input light - choose: - conditions: - condition: trigger