use HA since some days now, awesome ! I really like it and it just works.
Brilliant work here done !
Now i have a small problem with an automation, more with the thinking behind it.
This is my automation right now, works fine, if my wife or me is getting home, the light turns on, if it is 45 minutes before sunset and between 16.30 and 23 PM.
So far so good.
But if someone is already home, i would like to not run this automation.
So, only run this, if someone comes home, its 45 minutes before sunset and between 16.30 and 23 PM and no one else is already home.
I am not sure how to manage this… maybe someone can help.
- alias: Turn on Floor after Sunset
trigger:
- platform: sun
event: sunset
offset: "-00:45:00"
- platform: state
entity_id: device_tracker.babesiphone
state: 'home'
- platform: state
entity_id: device_tracker.iphonefritzbox
state: 'home'
condition:
condition: and
conditions:
- condition: time
after: '16:30:00'
before: '23:00:00'
- condition: or
conditions:
- condition: state
entity_id: device_tracker.babesiphone
state: 'home'
- condition: state
entity_id: device_tracker.iphonefritzbox
state: 'home'
action:
service: light.turn_on
entity_id:
- light.floor
- light.hallway
data:
brightness: 255
If trackers act like other groups, the group’s state should be “home” if any one tracker is home. Add a condition to your existing conditions that checks the group’s state.
to work with group is brilliant, that was the missing part.
Thank you for that.
And the Columbo question…
One last question:
Today i cam home at around 16.33 so the automation was armed.
From my understanding it should not have been going on, as the sunset will be in more then 45 minutes. But the lights went on, any idea why ?
the automation will only fire when the state of the family group changes - so if anyone in the group is home already, it won’t fire, which I guess you know as that is what you wanted. I.e. it won’t fire if everyone is home as the group state won’t change.
Other difference I have in a similar automation is I use from: to:
in the state trigger.
You could lose the time check and condition to simplify even more… you don’t really need that as the sunset should work and is almost always going to be within that time span anyway.
i am using this one know, this is working fine.
The Time check i just do, as i do not want to use later then 23PM,so do not wake someone with the light, i’d rather turn it on by hand then.
- alias: Turn on Floor after Sunset
trigger:
- platform: state
entity_id: group.family
from: 'not_home'
to: 'home'
condition:
condition: and
conditions:
- condition: time
after: '16:30:00'
before: '23:00:00'
- condition: state
entity_id: sun.sun
state: 'below_horizon'
action:
service: light.turn_on
entity_id:
- light.floor
- light.hallway
data:
brightness: 255