I would like to create an automation that can be activated by a virtual switch in the lovelace that every 2 minutes and 52 seconds gives the ignition input (light.turn_on) to infinity until I turn off the virtual switch.
Does anyone know how to do?
I would like to create an automation that can be activated by a virtual switch in the lovelace that every 2 minutes and 52 seconds gives the ignition input (light.turn_on) to infinity until I turn off the virtual switch.
Does anyone know how to do?
Although there may be better ways as I am no expert, if I wanted to do this I would create an input Boolean and show this in Lovelace.
I would then create an automation using the above Boolean turning from off to on as the trigger.
I would then use the repeat until action option and set the repeat to be turn on light with the 2m52s repeat until input Boolean is turned off.
Something like this maybe?
alias: Repeat
description: 'every 2m52s'
trigger:
- platform: state
entity_id: input_boolean.myswitch
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_boolean.myswitch
state: 'On'
action:
- service: light.toggle
target:
entity_id: light.mylight
- delay:
hours: 0
minutes: 2
seconds: 52
milliseconds: 0
- service: automation.trigger
target:
entity_id: automation.repeat
mode: single
Trigger when input_boolean.myswitch goes from ‘off’ to ‘on’
Toggle the light
Delays for 2:52
Trigger itself again (but only if input_boolean.myswitch is still on)
It does not work, apart from that it does not have to turn on/off the light but the automation, let me explain, I live in an apartment building, the staircase lights have a relay that switches on for 2 minutes and 52 seconds when you click the button, I with a Sonoff I set it that when it is turned on turns off after 0.5 seconds and this it is connected to other relay that in a nutshell and as if I press a button, this is why I want that virtual button to turn the automation on and off (which if it is active it will go to infinity)
I meant this input_boolean to an input helper which you can toggle from LoveLace
type: entities
entities:
- entity: input_boolean.myswitch
title: Toggle my switch
state_color: true
show_header_toggle: false
And toggle a light or toggle an automation…what’s the difference??
action:
- service: automation.toggle
Cant you use the lights off in the staircase as a trigger to run your automation? Put your input_boolean state there as a condition.
- alias: keep lights on in staircase
description: ""
trigger:
- platform: state
entity_id: input_boolean.your_virtual switch
from: "off"
to: "on"
for:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
condition:
- condition: state
entity_id: input_boolean.your_virtual switch
state: "on"
# condition not strictly necessary
action:
repeat:
while:
- condition: state
entity_id: input_boolean.your_virtual switch
state: "on"
sequence:
- service: light.turn_on
entity_id: light.staircase
- delay: 00:02:52
.....