If it's any help, I use the following python3 script.
Code:
import scheduleimport timeimport subprocessfrom gpiozero import MotionSensor pir = MotionSensor(21) def turn_monitor_on(): subprocess.run("DISPLAY=:0.0 xrandr --output HDMI-1 --auto --rotate left", shell=True) print("Monitor turned on.") def turn_monitor_off(): subprocess.run("DISPLAY=:0.0 xrandr --output HDMI-1 --off", shell=True) print("Monitor turned off.") def schedule_monitor_off(): schedule.clear() schedule.every(5).minutes.do(turn_monitor_off) print("Monitor off scheduled in 5 minutes.") while True: pir.wait_for_motion() turn_monitor_on() schedule_monitor_off() # Check periodically for new motion and run scheduled jobs. # If new motion is detected, break out to restart the cycle. while not pir.motion_detected: schedule.run_pending() time.sleep(1)Statistics: Posted by Pens — Sun Jun 22, 2025 10:46 pm