Going a bit further in automation I am running into a question.
I have a button, which acts as a trigger in an automation. That automation should activate a scene depending on time and sun state (‘above’ or ‘below’ horizon).
I guess I am now really missing an “else” inside a condition testing. If I would have to put the code in python:
if '7:00:00' < time < '8:00:00':
scene.turn_on['7247']
elif time < '9:00:00':
if sun.sun.state == 'above_horizon':
scene.turn_on['64040']
else:
scene.turn_on['7247']
Putting that in a yaml script I guess I have to create three separate scripts which are all activated in the action part of the automation. Or am I missing something ?
blind_scene_at_time:
alias: Activate a blind scene depending on time.
sequence:
- condition: time
after: '7:00:00'
before: '8:00:00'
- service: scene.turn_on
entity_id: scene.7247 #blinds semi close
blind_scene_at_time_and_sunrise:
alias: Activate a blind scene depending on time and sunrise
sequence:
- condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: 'above_horizon'
- condition: time
after: '8:00:00'
before: '9:00:00'
- service: scene.turn_on
entity_id: scene.64040 #blinds in daylight mode
blind_scene_at_time_and_sun_below_horizon:
alias: Activate a blind scene in time slot and sun below horizon
sequence:
- condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
- condition: time
after: '8:00:00'
before: '9:00:00'
- service: scene.turn_on
entity_id: scene.7247