Kindly help me this automation. I need to turn on a smart bulb in the morning after 7:00 am, but my problem is we have very frequent power cuts in our area. I am very new to Homeassistant. I am using the following automation. But it didnt worked today, Homeassistant was started today at 6:00 am.
alias: Morning Bulb
description: ""
trigger:
- platform: homeassistant
event: start
condition:
- condition: and
conditions:
- condition: state
entity_id: light.morning_bulb
state: "off"
- condition: time
after: "07:00:00"
action:
- service: light.turn_on
data: {}
target:
entity_id: light.morning_bulb
mode: single
What changes do I have to make in the automation so that the bulb should turn on after 7:00 am even if the power comes back at 7:10 am and the bulb must turn off at 9:30 pm.
Or trigger on HA start up, condition between the times you want it to happen. Could add another trigger at 7 if you want it to come on even if HA is already running.
If I change after to before. Let’s say I change it as below
trigger:
- platform: homeassistant
event: start
condition:
- condition: and
conditions:
- condition: state
entity_id: light.morning_bulb
state: "off"
- condition: time
before: "21:30:00"
action:
- service: light.turn_on
data: {}
target:
entity_id: light.morning_bulb
mode: single
Now if the server is turned on at 6am the light would turn on as both the conditions would be true. But I want the light to turn on only after 7am even of the server started before 7am.
So I guess I have to include another trigger at 7am if the server starts before 7am as suggested by @Arh .
Not sure you need the morning bulb off bit. As the automation is turning the bulb on and it can only do that if the bulb is off. If the bulb is on it won’t matter if you turn it on again.
And yes put the 7am bit in unless you want the bulb to come on whenever HA is started, Which if say it HA started at 00:01 your bulb would come on then, or basically every time HA starts except between 21:30 and 00:00
No problem, Once you get your head around what should be a condition and what should be a trigger, its pretty easy. Soon you will be answering these questions for others who pop in for help