zemepan
Posts: 1
Joined: Wed May 08, 2019 5:02 am

Rpi read status from alarm

Wed May 08, 2019 5:26 am

i have Rpi conected to alarm. There is HIGH at alarm output when motion sensors are activated. So signal from alarm is changing often.
I need to run script always, when at GPIO input is 30 minutes LOW continuously. (If in building is nobody)
I am new in Python. My idea is to save current time to file and then compare it. But i think it is not the best solution. any ideas please?

User avatar
MrYsLab
Posts: 312
Joined: Mon Dec 15, 2014 7:14 pm
Location: Noo Joysey, USA

Re: Rpi read status from alarm

Wed May 08, 2019 5:09 pm

There are several ways of doing this, but I prefer to use a package called apscheduler. The background scheduler feature works well for me https://apscheduler.readthedocs.io/en/l ... dscheduler

What you could do is to have your sensor use a callback that when the sensor goes low, start a background scheduler to do something in 30 minutes. If during that period, if the sensor goes high again, cancel the currently scheduled event. When the sensor goes low again, a new 30 minute timer will be set.

Return to “Python”