Quantcast
Viewing all articles
Browse latest Browse all 4861

Automation, sensing and robotics • Script lines to run only between certain times of day

Posting this here because I believe that there may be others running similar scripts for home security systems...

I've really thinned out a script that runs on a Pi that monitors my living room sliding door. There are a few lines that I've removed that are not relevant to the question. Imagine that I only want the "print" lines to run between certain times of day. How do I do this?

Code:

from gpiozero import Buttonimport requestsfrom signal import pausefrom time import sleepimport time#  Define inputs - these are GPIO numbersLRSlider = Button(21)  # Input from den entry door#  Define what to do when switches or PIRs are activedef LRSlideropen():    print("open")    def LRSliderclosed():    print("closed")    #  Define switch and PIR statesLRSlider.when_pressed = LRSliderclosedLRSlider.when_released = LRSlideropenpause()

Statistics: Posted by duckredbeard — Sun Dec 22, 2024 2:11 am



Viewing all articles
Browse latest Browse all 4861

Trending Articles