I have a automation that I have created but having problems with light timers
So, I have created
When:
Harmony hub activities changed
Sky to off
And if:
Confirm time is after 15:00 and before 1:00
Then do:
Turn off lights
Now what I would like to do is let’s say I want to turn off the hub from sky and it’s between 15:00 and 10:30 i would like the lights to stop on until 10:30 regardless what time I turn the hub of between 15:00 and 10:30. Also if I turn the hub off after 10:30 and before 01:00 to turn the lights off in 1 min of turning the hub off
I can not get this to work as every time I turn the hub off it will turn the lights off after 1 min which is fine after 10:30 but any time before that I want the lights to stay on until 10:30.
I hope you can all help as it would have been ideal if the (then do:) had a set time option to turn the lights of before set times and after.
it would really help if you did the formatting as @LiQuid_cOOled indicated. makes it easier for us to edit your automation.
a few questions for you
you said:
do you mean that you would like the lights to stay on until 10:30?
if the lights are on because someone turned them on, but the hub never turned on or off between 15:00 and 10:30, do you want the ligthts to turn off at 10:30? in other words, do you want the lights to turn off always at 10:30 unless the hub is still on? or do you want them to turn off only if the hub was turned off during that time?
if you want the lights to turn off always at 10:30 unless the hub is on, that’s super easy… just create an automation that triggers at 10:30 and conditions that the hub is off then turn the light off.
Sorry new to home assistant as just installed it a week ago and learning all the time, I will post the script properly when back at home as now left and can not access the system.
What happens is we watch tv and when it gets dark the lights come on which is not the problem, So
Sometimes I stay up late let’s say 23:00 and I turn the lights off but instead I did a automation that when I turn the tv off which is controlled by the harmony hub, the state changes from anything on scene to off it then triggers the lights to go off after 1 min delay, Perfect. I set this to work between 22:30 and 01:00 and works great if I turn the hub off after 22:30 time frame.
Now The problem, let’s say instead I am abit tired and want to go to bed early say 20:00 and I turn of my Tv using the harmony state again changes from on to off which works, But this time I wanted The lights to stay on and wait until 22:30 then turn the lights off as the harmony has changed it state a couple of hours ago. But what happens is the lights stay on after 22:30 has passed and nothing happens as the trigger happened before the 22:30 and not after.
So basically turn the lights off straight away after 22:30 when harmony hub is off and anything before that time leave the lights on up until 22:30 then turn the lights of when harmony hub is off
i got all that, but the scenario you didn’t clarify that i was asking about is what if someone turns the lights on at 19:00 manually. the harmony is off and stays off. what do you want to happen? do you want it to turn off at 22:30 also? or in that case do you want it to stay on?
if you want it to turn off at 22:30 also, then the “stay on if i turn it off earlier” is really immaterial… and all you’re saying is “turn the lights off always at 22:30 unless harmony is on… in which case turn it off 1 minute after harmony turns off”… which is super easy.
No I don’t want anything to happen to the harmony hub all I am wanting to do is asking home assistant to monitor harmony hub state and if the state is off between 18:00 and 22:30 turn the lights of at 22:30 if it’s after 22:30 and the harmony hub state is off turn the lights off after 1 min delay
So if any of the harmony hub state is other than off it will Just ignore it and leave the lights alone meaning on until the state changed to off
If someone tuns the lights on the harmony hub does nothing what ever state it’s in apart from if it changes its state to off which is the trigger
Remember when the harmony is not been physically turned off by power it just a state change from something been on and the harmony hub changes to off in home assistant
if someone turns on the lights. and no one touches the harmony hub. the hub is off. was off all day. never on. what do you want to happen to the lights at 22:30?
If the Harmony Hub is turned off between 18:00 and 22:30 have HA turn the lights off at 22:30. (note, i’m unclear why the room sensor wouldn’t turn the light off as in case 3)
If the Harmony Hub is off after 22:30, turn the lights off after waiting 1 minute after the hub is off.
if the light is on manually and the hub was never turned on, leave the light on
note however, that there are a number of scenarios that are still wonky. so consider doing this simplfiied approach which i think @LiQuid_cOOled and i both prefer… but this does turn off the lights at 22:30 if the harmony is off, regardless of why it’s off.
trigger:
- platform: time
at: "22:30:01"
- platform: state
entity_id:
- remote.harmony_hub
to: "off"
for:
minutes: 1
condition:
- condition: time
after: "22:30:00"
before: "01:00:00"
- condition: state
entity_id: remote.harmony_hub
state: "off"
for:
minutes: 1
action:
- service: light.turn_off
target:
entity_id: light.great_room_lights
as you learn all of this, one piece of advice is that home automation gets messy and error prone if you think and program in a “state machines” mindset. ie, “when this happens then later do that” or even worse is multi-step state machine… “when this happens, wait until that happens, etc, then do x”
your inital mindset “if i turn off the harmony hub, then later at 22:30 turn the lights off”… that’s a state machine mindset.
what my code did was to reframe it as a rule:
turn the light off when:
the harmony hub has been off for at least a minute and also it’s past 22:30