Ive setup the below, which works well to turn the lights on.
However im confused about the timer.
When there is motion in the room, the timer then starts to count down, however i was expecting that more motion in that room, would keep resetting the timer back to 30 minutes?
however it just keeps counting down? which means when it gets down to 0, all lights go off, even if there has been motion the room?
do i need to add in a stop function as well? i dont see a “reset” option?
where am i going wrong?
Host system
Hostname
hassio
System
HassOS 3.5
.
configuration:
timer:
timer_motion_living_room:
duration: '00:30:00'
automation:
############### living room ###############
- id: livingroomlightsonmotion
alias: living room lights on motion
trigger:
- entity_id: binary_sensor.living_room
from: 'off'
platform: state
to: 'on'
condition:
condition: state
entity_id: sun.sun
state: below_horizon
action:
- data_template:
entity_id: group.room_living_room_all_lights
service_template: switch.turn_on
- service: timer.start
data:
entity_id: timer.timer_motion_living_room
- id: livingroomlightsoffafter30minnomotion
alias: living room lights off no motion 30min
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.timer_motion_living_room
action:
- data_template:
entity_id: group.room_living_room_all_lights
service_template: switch.turn_off
i thought using a timer would be easier, as it means i can load this into the UI and have the misses then check/update it, if she wants more dynamically
What makes you say the timer keeps counting down? Are you just viewing it in the UI? Don’t believe it. Have you actually tested it – i.e., caused motion, waited, say 15 minutes, then caused more motion, and then timed how long it takes for the lights to go off? I suspect you’ll find that the timer is restarting when new motion is detected (assuming, of course, the binary sensor goes off and back on. If the binary sensor is staying on, that’s a different story.)
Huh? What do you mean, “set the timer”? Calling the timer.start service will restart a timer that is already running.
That’s a good suggestion! However, note that this doesn’t take into account whether the sun is up or down, and whether or not the first automation actually triggered (meaning it might turn the light off even if it was manually turned on during the day.)
I mean I frequently still keep getting notifications for the bug about the timer.start service not working as documented, so I presumed it still hasn’t been fixed, and the workaround was to start it with the new time.
Wow, that issue is extremely old, and it seems all the fuss may just be about the frontend not properly showing a restarted timer. I’ve never had an issue with restarting a running timer by using the timer.start service.
The only thing unexpected I’ve seen with timers is that restarting a running timer does not cause a timer.restarted event, but rather a timer.started event. See this post for more details.
hi,im using this one in my automations,my binary_sensors are xiaomi/aqara door/window sensor so they refresh state after 2 mins,i dont know about refesh time of yours but maybe you can play with the wait_template