penright
(Paul Enright)
April 18, 2022, 4:20pm
1
using this input_boolean
input_boolean:
shop_lock:
name: 'Shop is Lock'
There are a lot of examples of using MQTT as a trigger. I have a button that action is “single”, “double”, and “long”.
This one will turn on the boolean.
automation:
- alias: Shop Lock From Click
id: Shop Lock From Click
trigger:
- platform: mqtt
topic: "zigbee2mqtt/0x00xxxxx"
condition:
- condition: template
value_template: "{{ trigger.payload_json['action'] == 'single' }}"
action:
- service: input_boolean.turn_on
entity_id: input_boolean.shop_lock
What I would like is some sort of combination of single and double
For example, a ‘single’ a ‘double’ then a ‘single’
How do you get it to read mqtt in a wait_template?
I am guessing I need a different way, since I guessing the json is loaded off of the first trigger.
automation:
- alias: Shop Lock From Click
id: Shop Lock From Click
trigger:
- platform: mqtt
topic: "zigbee2mqtt/0x00124xxxxxx"
condition:
- condition: template
value_template: "{{ trigger.payload_json['action'] == 'single' }}"
action:
- wait_template: "{{ trigger.payload_json['action'] == 'double' }}"
timeout:
seconds: 5
continue_on_timeout: false
- wait_template: "{{ trigger.payload_json['action'] == 'single' }}"
timeout:
seconds: 5
continue_on_timeout: false
- service: input_boolean.turn_on
entity_id: input_boolean.shop_lock
tom_l
April 19, 2022, 3:27am
2
Use wait for trigger instead of wait template.
penright
(Paul Enright)
April 19, 2022, 2:57pm
3
That got me close. The trigger condition is satisfied with and press. I am not sure of the correct syntax for not only a trigger of an MQTT payload but only if it is a double click.
This was my last try …
input_boolean:
shop_lock:
name: 'Shop is Lock'
automation:
- alias: Shop Unlock From Click
id: Shop Unlock From Click
trigger:
- platform: mqtt
topic: "zigbee2mqtt/0x00124b0025143172"
condition:
- condition: template
value_template: "{{ trigger.payload_json['action'] == 'single' }}"
action:
- wait_for_trigger:
- platform: mqtt
topic: "zigbee2mqtt/0x00124b0025143172"
value_template: "{{ trigger.payload_json['action'] == 'double' }}"
timeout:
seconds: 5
continue_on_timeout: false
- service: input_boolean.turn_off
entity_id: input_boolean.shop_lock
- alias: Shop lock From Click
id: Shop Lock From Click
trigger:
- platform: mqtt
topic: "zigbee2mqtt/0x00124b0025143172"
condition:
- condition: template
value_template: "{{ trigger.payload_json['action'] == 'long' }}"
action:
- service: input_boolean.turn_on
entity_id: input_boolean.shop_lock
penright
(Paul Enright)
April 21, 2022, 1:44pm
4
In the Discord Automation channel, @TheFes gave me the fix.
Anyone running across this thread, here is the working yaml …
automation:
alias: Shop Unlock From Click
id: Shop Unlock From Click
trigger:
platform: mqtt
topic: “zigbee2mqtt/0x00124b00xxxxx”
value_template: “{{ value_json.action }}”
payload: “single”
condition: []
action:
wait_for_trigger:
platform: mqtt
topic: “zigbee2mqtt/0x00124bxxxxx”
value_template: “{{ value_json.action }}”
payload: “double”
timeout: “00:00:05”
continue_on_timeout: false
wait_for_trigger:
platform: mqtt
topic: “zigbee2mqtt/0x00124bxxxxxx”
value_template: “{{ value_json.action }}”
payload: “single”
timeout: “00:00:05”
continue_on_timeout: false
service: input_boolean.turn_off
entity_id: input_boolean.shop_lock