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

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