My current code works to change the scene based on motion and time of day based on TOD sensors I setup.
However I wanted to expand it and for each chose condition I wanted to add to checks for whether the lights were off and whether a helper I have called sleep mode is activated or not . I could not get this to work without having to create an automation for each scene I wanted.
It looked like this is something that could easily be done using a template without creating so many unneeded lines of code and automations. I added some comments to give an idea of what I would like to do as I want to refine the additional conditions over time but wanted guidance for the structure.
Thanks for your hlep
- id: '1608850590263'
alias: TODSceneRoomActivation
trigger:
- platform: state
entity_id: binary_sensor.nursery_motion
to: 'on'
action:
- choose:
- conditions:
- condition: state
# Add condition to execute only if light is on and sleep mode is off to all of these
entity_id: binary_sensor.mode_manager_early_morning
state: 'on'
sequence:
- service: scene.turn_on
data:
entity_id: scene.zoe_earlymorning
- conditions:
#Excute only if all lights were off in the room
- condition: state
entity_id: binary_sensor.mode_manager_morning
state: 'on'
sequence:
- service: scene.turn_on
data:
entity_id: scene.zoe_morning
- conditions:
- condition: state
entity_id: binary_sensor.mode_manager_afternoon
state: 'on'
sequence:
- service: scene.turn_on
data:
entity_id: scene.zoe_afternoon
- conditions:
# only execute if my home helper is on
- condition: state
entity_id: binary_sensor.mode_manager_evening
state: 'on'
sequence:
- service: scene.turn_on
data:
entity_id: scene.zoe_evening