Hi community,
I think i have a question that can be solved easily:
I have an automation that turns on the lights in the washing room triggered by a sensor. I build in a delay for 5 minutes, so if the door is not closed the lights turn of.
I made the same automation: when door sensor is closed turn of light.
This also works perfectly.
Only issue i have is when I reopen the door within 5 minutes the lights do not turn on. What can I change bout this?
alias: "Washok: Licht aan"
description: ""
trigger:
- type: opened
platform: device
device_id: 643783afc925b439099a03bbf5bb7e61
entity_id: 5a1bc2494707045d08cb39147fb318a4
domain: binary_sensor
condition: []
action:
- type: turn_on
device_id: 8cbcf806d256ca20317671b647cc56ec
entity_id: 587c07acf0ec6a0abe2d5e8b4441964b
domain: light
brightness_pct: 100
- delay:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
- type: turn_off
device_id: 8cbcf806d256ca20317671b647cc56ec
entity_id: 587c07acf0ec6a0abe2d5e8b4441964b
domain: light
mode: single
tom_l
December 12, 2023, 11:53pm
2
Try this:
trigger:
- platform: state
entity_id: binary_sensor.your_door_here
to: 'on'
- platform: state
entity_id: binary_sensor.your_door_here
to: 'off'
for:
minutes: 5
action:
- service: "light.turn_{{ trigger.to_state.state }}"
target:
entity_id: light.your_light_here
mode: single
Also some free advice: Why and how to avoid device_ids in automations and scripts
This seems to work for the lights going on and off, but it is not turning it off after 5 minutes now
tom_l
December 13, 2023, 9:14pm
4
If you included this in the trigger:
The lights will turn off after the door remains closed for 5 minutes.
it needs to be the otherway around, if someone does not close the door so it stays open, it needs to be turned off in 5 minutes
tom_l
December 13, 2023, 9:40pm
6
Try this:
trigger:
- id: 'on'
platform: state
entity_id: binary_sensor.your_door_here
to: 'on'
- id: 'off'
platform: state
entity_id: binary_sensor.your_door_here
to: 'on'
for:
minutes: 5
- id: 'off'
platform: state
entity_id: binary_sensor.your_door_here
to: 'off'
action:
- service: "light.turn_{{ trigger.id }}"
target:
entity_id: light.your_light_here
mode: single