I am trying to make a double click binary sensor, on single click it is supposed to activate script.kontor_kveld on double click it is supposed to activate script.kontor_vanlig
What happens is single click: 2700ms after the click “script.kontor_kveld” is triggered. This is expected behavior.
What happens on a double click: Immediately after the first click, a script is activated (expected), but the script activated is “script.kontor_kveld”, that is not excepted.
Any tips on what I am doing wrong here?
- alias: "Test dobbel"
trigger:
- platform: state
entity_id: binary_sensor.kontor_dor_rt
to: 'on'
mode: single
action:
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.kontor_dor_rt
to: 'on'
timeout:
milliseconds: 2700
continue_on_timeout: true
- choose:
- conditions:
#single click action if wait is over 2700ms
- condition: template
value_template: "{{ not wait.completed }}"
sequence:
- service: script.turn_on
entity_id: script.kontor_kveld
#double click action
default:
- service: script.turn_on
entity_id: script.kontor_vanlig
I got help on this, in case anybody else has the same problem. The problem was the value_template: “{{ not wait.completed }}” it has top be exchanged with “{{ wait.remaining == 0 }}”
Thanks for posting this! I’m playing with something similar.
I tested using notifications and wait.completed definitely doesn’t return anything for wait_for_template. The equivalent for wait_for_template would be wait.trigger
wait.completed Exists only after wait_template. true if the condition was met, false otherwise
wait.trigger Exists only after wait_for_trigger. Contains information about which trigger fired. (See Available-Trigger-Data.) Will be none if no trigger happened before timeout expired
wait.remaining Timeout remaining, or none if a timeout was not specified
So another option is to check for "{{ wait.trigger == None }}" instead of "{{ not wait.completed }}" or "{{ wait.remaining == 0 }}"
EDIT: Removed the single quotes around None; If you include them the test will fail.
This is great. I made a automation to turn my single button switch (Philips Hue wall switch module) in to a multi function switch with single, double and triple click.
OK so in my case re-reading the documentation I suppose it is right since they mention that wait.completed is only applicable for when you use the wait_template while wait.trigger is available for wait_for_trigger. So i used "{{ wait.trigger is none }}" instead of the == calculation you used. Works the same way. just FYI!
I did a simple automation to add a double click to a zigbee switch. The switch is a tuya wall switch module WHD02.
I can’t dissociate the input rocket wall switch connected to the device from the lamp also connected to it. So when the user pulses the rocket the light will toggle.
With this automation, a second click in less than a second, will toggle a secondary light (z_esc_2), while the primary one (z_esc), will toggle twice and remain in the original status.
To do the automation I created a helper variable entity_id: input_datetime.esc_last_click to which I assign a value (now() ) then I check the last change so, the value is not used at all.
I put the condition in the actions, not an entering condition, because I need to get in to change the helper variable.