- Fix Z2M automation to listen for Z2M events

This commit is contained in:
nwithan8 2023-08-16 17:22:55 -06:00
parent 63aa5050a4
commit 9ab215f54a
1 changed files with 217 additions and 206 deletions

View File

@ -26,8 +26,7 @@ blueprint:
selector:
device:
filter:
integration: zha
model: TS004F
integration: mqtt
mode_tracker:
name: Mode tracker
@ -61,19 +60,33 @@ blueprint:
filter:
domain: input_number
base_topic:
name: Zigbee2MQTT Base mqtt topic
description: The base topic configured in Zigbee2MQTT. If you haven't changed this, leave the default here ("zigbee2mqtt")
default: zigbee2mqtt
# Queued, to ignore non-matched events but capture existing ones
mode: queued
max: 20
max_exceeded: silent
variables:
trigger_variables:
base_topic: !input base_topic
trigger:
- platform: mqtt
topic: "{{ base_topic }}/+/action"
action:
- variables:
light: !input "light"
dial: !input "dial"
mode_tracker: !input "mode_tracker"
hue_tracker: !input "hue_tracker"
brightness_tracker: !input "brightness_tracker"
color_tracker: !input "color_tracker"
command: "{{ trigger.to_state.state }}"
dial_topic: "{{ base_topic }}/{{ device_attr(dial, 'name') }}/action"
command: "{{ trigger.payload }}"
single_pressed: "{{ command == 'single' }}"
double_pressed: "{{ command == 'double' }}"
rotated: "{{ command in ['rotate_right', 'rotate_left'] }}"
@ -154,15 +167,13 @@ variables:
{%- set val = max_color - (diff % max_color) -%}
{%- endif -%}
{{ val | int }}
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input dial
action:
# Process current event
- choose:
# Verify that the dial is the one that triggered the event
- conditions:
- "{{ trigger.payload != ''}}"
- "{{ trigger.topic == dial_topic }}"
sequence:
- choose:
# If event was a dial turn
- conditions: