When turning on backyard light I want to always turn on my light.backyard_light on, and light.backyard_light_2 only if the was motion in the backyard in the last 30 minutes. I tried to achieve that with the following action in my automation. But, I’m doing something wrong here. Can anyone point me out what’s the correct way to achieve this? This is my code:
action:
service: light.turn_on
data_template:
entity_id: >
{% if (as_timestamp(now()) as_timestamp(states.binary_sensor.backyard_motion.last_changed)) > 1800 %}
light.backyard_light
{% else %}
light.backyard_light
light.backyard_light_2
{% endif %}