- Fix(?) payload extraction for Z2M

This commit is contained in:
nwithan8 2023-08-20 00:00:11 -06:00
parent 9ab215f54a
commit 3f5b677c88
1 changed files with 8 additions and 3 deletions

View File

@ -75,7 +75,7 @@ trigger_variables:
trigger: trigger:
- platform: mqtt - platform: mqtt
topic: "{{ base_topic }}/+/action" topic: "{{ base_topic }}/+"
action: action:
- variables: - variables:
@ -86,14 +86,19 @@ action:
brightness_tracker: !input "brightness_tracker" brightness_tracker: !input "brightness_tracker"
color_tracker: !input "color_tracker" color_tracker: !input "color_tracker"
dial_topic: "{{ base_topic }}/{{ device_attr(dial, 'name') }}/action" dial_topic: "{{ base_topic }}/{{ device_attr(dial, 'name') }}/action"
command: "{{ trigger.payload }}" command: >
{%- set command = '' -%}
{%- if 'action' in trigger.payload -%}
{%- set command = trigger.payload.action -%}
{%- endif -%}
{{ command }}
single_pressed: "{{ command == 'single' }}" single_pressed: "{{ command == 'single' }}"
double_pressed: "{{ command == 'double' }}" double_pressed: "{{ command == 'double' }}"
rotated: "{{ command in ['rotate_right', 'rotate_left'] }}" rotated: "{{ command in ['rotate_right', 'rotate_left'] }}"
positive: "{{ command == 'rotate_right' }}" positive: "{{ command == 'rotate_right' }}"
step_size: > step_size: >
{% if rotated %} {% if rotated %}
{{ trigger.to_state.attributes.action_step_size | int }} {{ trigger.payload.action_step_size | int }}
{% else %} {% else %}
{{ 0 }} {{ 0 }}
{% endif %} {% endif %}