I’m wanting to add an automation but am struggling to get my head around it properly.
What I want to do it turn on the lounge lights at sunset, but only if me or my wife are at home (any of us, not both), and only if the Input Boolean switch is turned on.
Here’s the code I have at the moment
automation:
- alias: "Lounge Lights on at Sunset"
trigger:
- platform: sun
event: sunset
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.lounge_lights_sunset
state: 'on'
- condition: or
conditions:
- condition: state
entity_id: 'device_tracker.jonos_iphone'
state: 'home'
- condition: state
entity_id: 'device_tracker.wifes_iphone'
state: 'home'
action:
- service: scene.turn_on
entity_id: scene.lounge_lights_on
Does this look OK, or does it need some tweaking?
I’ve seen some examples in the docs’ that use ‘group.all_devices’ like this
- condition: state
entity_id: group.all_devices
state: ‘home’
If I were to do this would I have to create a group and add any devices I wanted to it, and if so would that only work when both/all people in the group were home?