@broyuken1 wrote:
I have an automation I’m trying to set up but am getting stuck at the end.
- id: automaticdoorlights alias: Lights - Doors description: '' trigger: - entity_id: binary_sensor.kid1_closet_door_sensor, binary_sensor.kid2_closet_door_sensor platform: state - entity_id: binary_sensor.kid1_closet_door_sensor, binary_sensor.kid2_closet_door_sensor for: 0:01:00 from: 'off' platform: state to: 'on' action: - data_template: entity_id: '{{ trigger.entity_id.replace("binary_sensor", "light").replace("_door_sensor", "_light") }}' transition: 2 service_template: '{% if "trigger.for" == "0:01:00" %}light.turn_off{% elif trigger.to_state.state == "on" %}light.turn_on{% elif trigger.to_state.state == "off" %}light.turn_off{% endif %}'
It’s a contact sensor on a closet door with a light that should turn on when it’s opened and turn off when it’s closed. That part all works fine. I also want the light to turn off if the door is left open for a minute. I have the trigger set up, and I have the if/then statement part recognizing the for part, but I’m guessing that the issue is that part of the statement is returning a string and part is returning an integer but I’m not 100% sure. Does anyone have advice?
Thanks in advance.
Posts: 2
Participants: 2