chore(z2m): move from mqtt topic to device action (#3)

This commit is contained in:
Damien
2024-11-28 16:11:51 +01:00
committed by GitHub
parent 95087e88c8
commit 05333fc13e
2 changed files with 210 additions and 163 deletions

View File

@@ -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