Hello there,
I’ve got following automation that works perfectly well apart from if/then condition. If i remove the condition and only leave one of the switches (ie switch.stairs_light_night) it works fine.
What is the best wat to do it with conditions? I.e. depending on the hour i need one or another switch to turn on. Is there any way to avoid two automation records?
- id: '1536778262822'
alias: Stairs lights on
trigger:
- entity_id: binary_sensor.motion_sensor_158d00023756b5
from: 'off'
platform: state
to: 'on'
condition:
- below: '30'
condition: numeric_state
entity_id: sensor.illumination_158d00023756b5
action:
- data:
entity_id: '{% if now().hour > 22 or now().hour < 6%} switch.stairs_light_night {% else %} switch.stairs {% endif %}'
service: switch.turn_on
i didnt find elegant way to do it so trying to do achieve my goal with two almost same automations now.
This works:
- id: '1536778262822'
alias: Stairs night lights on
trigger:
- entity_id: binary_sensor.motion_sensor_158d00023756b5
from: 'off'
platform: state
to: 'on'
condition:
- below: '30'
condition: numeric_state
entity_id: sensor.illumination_158d00023756b5
- before: '07:00:00'
condition: time
action:
- data:
entity_id: switch.stairs_light_night
service: switch.turn_on
but when i try to add condition: before: '22:00:00' it fails. I tried to play around with condition: or` with no success so far. How can i do it properly??