I have a motion sensor on the porch, and am using the porchlight app to turn on the light when someone comes onto the porch. Other than needing some better placement and tuning (our cat tends to set it off) it works pretty well.
We have presence sensors in each of our cars. I’d like the porchlight to come on when a car arrives, and stay on for 10 minutes. Eventually, I’ll want it to stay on for 10 minutes, or until the front door is opened and closed again… but there’s no sensor on the front door yet.
Unfortunately, from the logs, it looks like the presence sensors have a lot of false entries. I have my truck’s sensor set to notify me on my iPhone, and a couple times each night, it’ll send a message saying the truck left, then somewhere between 5 seconds and 5 minutes later, it’ll say it’s back.
Can anyone help me with the code I’d need to manage this?
Here’s the pseudocode:
if one of the two presence sensors arrives:
if the same sensor left more than 5 minutes ago:
turn on the light, and schedule it to shut off in 10 minutes.
else if motion sensor sees motion
turn on the light, and schedule it to shut off in 5 minutes, resetting any existing schedule
Any suggestions? I’m happy to crib code, and the porchlight code is easy enough to understand, but the “more than 5 minutes ago” part for the presence sensors is harder, and I’ve not found any examples yet.