So, on my back patio I have lights that are controlled by a smart switch, and a fountain that is controlled by an outdoor smart plug. So what I’d like to do is, at the simplest level have the smart switch control only the lights when flicked on/off. And then more flexibly toggle the fountain and light together say, when the switch is consecutively toggled twice in a quick succession.
Or maybe there is another idea that I’m not aware of. I’m still a newbie at alot of this and there sure is a lot to discover. Hope this is clear.
Unless your switch’s integration produces different events for a “double-flick” your best option is probably to use a series of Wait for Trigger actions to “listen” for the on-off-on and off-on-off of the switch.
Thanks for the response Drew, can’t wait to give this a try.
This is going to work … many thanks!
I’m still struggling with this. I have the “Wait for Trigger” actions coded for on-off and it triggers as desired, though I can’t find the way to code the action after the “Wait for Triggers” fires. When I place the action, (and just for clarity … while I’m testing I’m just sending out a text), It “falls through” and sends a text every time the automation runs. I don’t know what I’m missing. Here’s the code;
alias: "TJT trigger testing "
description: Two key presses - turns on Fountain
trigger:
- platform: device
type: changed_states
device_id: 81e80c6b6bf3e7ccdbb69731f231f6d2
entity_id: 7063835753eef6e1e354dbd5dc9a74fd
domain: switch
condition: []
action: - wait_for_trigger:
- platform: device
type: turned_on
device_id: 81e80c6b6bf3e7ccdbb69731f231f6d2
entity_id: 7063835753eef6e1e354dbd5dc9a74fd
domain: switch - platform: device
type: turned_off
device_id: 81e80c6b6bf3e7ccdbb69731f231f6d2
entity_id: 7063835753eef6e1e354dbd5dc9a74fd
domain: switch
timeout:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
continue_on_timeout: false
enabled: true
- platform: device
- service: notify.twilio
data:
message: Toggle from back porch lights
target: 0
enabled: true
mode: single
Impossible to tell what is wrong with your code, please format it properly.
You need a wait for each subsequent action.
Trigger "On"
- Wait For Trigger "Off" > Wait For Trigger "On" > Switch On
… which could get very long if you’re using Device triggers and actions, but by using State triggers, the Wait trigger variable and a little bit of Templating we can handle turning the fountain both on and off in a single automation.
trigger:
- platform: state
entity_id: 7063835753eef6e1e354dbd5dc9a74fd
to:
- 'on'
- 'off'
from:
- 'on'
- 'off'
condition: []
action:
- wait_for_trigger:
- platform: state
entity_id: 7063835753eef6e1e354dbd5dc9a74fd
to:
- 'on'
- 'off'
timeout: 5
continue_on_timeout: false
- wait_for_trigger:
- platform: state
entity_id: 7063835753eef6e1e354dbd5dc9a74fd
to:
- 'on'
- 'off'
timeout: 5
continue_on_timeout: false
- service: switch.turn_{{ wait.trigger.to_state.state }}
entity_id: switch.YOUR_FOUNTAIN_SWTICH
mode: single
@Didgeridrew
Drew, your code is working out very well. Very nice of you to share your expertise this way. Thanks for making this so easy for me, it saved me a lot of the heartburn it would have taken me to get there.