Hello,
I’m just getting to grips with Home Assistant and now trying a few automations.
I have the first part working, to turn on a light if a certain condition is met, but I want the light to turn off - either after so many minutes or at a certain time - but only if the light came on because of the automation. In my mind I see this as setting a flag to say ‘automation triggered light’ and then at the off time checking if the flag is set or not? How should I approach that or is there a simpler method?
- id:
alias: morning
trigger:
- at: 06:59:08
platform: time
condition:
- condition: state
entity_id: media_player.living_room
state: playing
action:
- alias: ''
data:
entity_id: light.tradfri_bulb_e27_ws_opal_980lm_3
service: light.turn_on
first @cyn, please post any code per the blue box at the top of the page.
As to the OP,
you could try also turning on an input_boolean when you turn on the the light with the automation. Then you could check the status of the input_boolean after a certain amount of time has passed and if ‘on’ then turn off both the light and the input_boolean.
Ironically I literally just posted the following in another thread to someone who was also having a hard time figuring it out:
“The way it works is that you copy your code snippet from your configuration.yaml file, paste it into the reply box, then you need to highlight all of the code you just pasted in and then click on the “</>”. Every once in a while it may do something funky with the first line so you may have to play with that but it’s fairly rare that you have to mess with it.”
it’s way easier to use the button below escape and next to the number one, ` symbol. Use 3 in a row before your code and 3 in a row after your code. It also does some pretty formatting with colors and crap.
using </>:
this:
# Some Section for my house
some_section:
attribute: "Foo Foo"
vs
using three `:
this:
# Some Section for my house
some_section:
attribute: "Foo Foo"