Hi Everyone, I’m new here so i’ll start by introducing myself.
I’m an alarm and security engineer by trade. I install high end alarm and CCTV systems amongst other things, but that’s my main thing.
I’m relatively new to Home automation, I’ve played around with arduinos and PIs before, but nothing too serious.
I’ve liked the idea of automating my home for a while, and it seems like home assistant will be perfect for my needs! if i can work it out on my own place, it’s something i could offer to my domestic customers in the future. as well.
but for now, i’d like to automate my own home…
I have alarm detectors in every room, and light switches as well. I’d like to replace my switches for momentary ones so that when pressed, the light turns on and stays on until either the switch is pressed again, or the motion sensor hasn’t triggered for an hour.
I’ve had a look at the rules and automations, but i can’t work out how to make a delay timer which is restarted on every trigger. i’m sure it’s super simple, but i just can’t see it!
another option I’d have is to just use an arduino for all the I/O programming in which I could write programs to do the above task, and communicate to Hassio via MQTT but i’d prefer to keep everything on the pi if it’s possible.
I’ve got many other things i’d like to do as well, but this seems like a good simple one to start with!
Thanks in advance everyone! i’m so excited to see what HAssio can do!
I use the timer integration within home assistant to achieve this, and it sounds like it could be useful to you as well.
I use motion and other inputs depending on which room it is to determine if the room is occupied or not, and once the motion sensor turns off, I start a timer which will turn off the lights unless it is reset or paused by new motion or other input. Here’s an example from my hallway:
Another potential way to do this is using the for option in the state trigger. It’s kind of hard to tell, though, since you didn’t provide many details.
Let’s say you have a binary sensor that indicates motion. You can turn the light off once there has been no motion for an hour like this:
trigger:
- platform: state
entity_id: binary_sensor.MOTION
to: 'off'
for:
hours: 1
action:
- service: light.turn_off
entity_id: light.LIGHT
This will trigger one hour after the sensor goes from detecting motion ('on') to not detecting motion ('off'.) The sensor has to stay 'off' for the entire hour for it to trigger.
I think that Phil’s example will serve you better as it triggers on the ‘end’ of motion.
You may still have issues as if you sit down to watch a film (say) the lights will go off an hour in, but you can adjust the time if you see this. (When people set off an on automations like this, you often see them jumping around)
You might want the motion detection to ‘on’ to turn your light on with a second automation.