Hello all, Im sure this is an easy automation but I cannot seem to find it anywhere how to do this properly. Any help is greatly appreciated. Thank you.
My system:
Home Assistant 0.84.6
Sonoff Basic module flashed w/ Tasmota 6.4.0
What I want to achieve:
I want to run an automation; script or a sequence that when the sonoff switch is turned on (or off) it waits or pauses 1 second then turns off, waits or pauses 2 seconds then turns on, waits or pauses 1 second then turns off, waits or pauses 2 seconds then turns on, waits or pauses 1 second then turns off.
Pretty much I want the switch to turn on and off but wait 1 or 2 seconds in between each toggle. I need the switch to be on 3 times in total.
This is what I have tried with no successâŚ
- id: â1545808863578â
alias: Turn Truck On
trigger:
- platform: state
entity_id: switch.sonoff1
to: âonâ
from: âoffâ
condition: []
action:
service: script.turn_on
entity_id: script.turn_on_truck
I have a script set up so that after 25 minutes I get a flashing light to give me a 5 minute warning that the light is about to be turned off. You can use something similar to do what you want:
You call scripts and automations by the alias (with spaces replaced by underscores).
Like this:
- id: '1545847390275'
alias: Truck on
trigger:
- entity_id: switch.truckon
from: 'off'
platform: state
to: 'on'
action:
- service: script_turn_on
entity_id: script.tuck_on
Also notice that you called your script alias âTuck Onâ not âTruck Onâ. You might want to fix that in the script and then in the automation. Unless thatâs what you intendedâŚ
Hey finity, Thank you for your response. I have been at this for the last 5-6 hours and I can not get the switch to toggle between on and off. Here is what I have on my automations/scripts .yaml files.
Are you using two different switches in this operation? One called âtruck_onâ & one called âtruckonâ. That is the way you have it in your screen shots above: âswitch.truck_onâ in the automation and âswitch.truckonâ in the script.
If thatâs correct and is actually how you have it set up then ignore the rest of this post and weâll have to try to figure out some other problemâŚ
But if you are really trying to use the same switch in the trigger for the automation as you are trying to control in the script I think you may need to do something a little different for this to work.
Every time the script turns off the switch and then turns it back on again the automation will trigger but since the script isnât finished yet Iâm rally not sure what will happen then.
I think you should create an input boolean to use to trigger the whole sequence.
input_boolean:
truck:
name: Truck Control
# these next two things are optional
initial: off
icon: mdi:car
Then in your automation use the boolean to trigger the script:
- id: '1545847390275'
alias: Truck on
trigger:
- platform: state
entity_id: input_boolean.truck
to: 'on'
action:
- service: script_turn_on
entity_id: script.truck_control
Thank you SOOOO much for your help man you lead me in the right direction. I finally found my issue and I got it to work, In the script I had to change the file to a different on/off command. Here is my new script file.