feat: add end-to-end relay test scripts for both Pis#363
feat: add end-to-end relay test scripts for both Pis#363MateoLostanlen wants to merge 12 commits into
Conversation
MateoLostanlen
commented
Apr 29, 2026
- New watchdog/main_pi/relay_check.py and watchdog/pi_zero/relay_check.py: ping the controlled device, drive the relay LOW for POWER_OFF_TIME, verify the device drops, restore HIGH, and verify it returns. Useful after transport to confirm GPIO -> relay -> power wiring is intact.
- Pi Zero script supports --relay {main,cams,all}; cams test pings the first configured camera as a proxy for the 12V rail.
- Drop detection requires two consecutive failed pings and runs across the full cut window to avoid false positives from transient packet loss or slow-discharging loads.
- Both scripts restore relays HIGH in finally to avoid leaving a rail off on early exit.
Avoid pytest auto-collection of files matching test_*.py pattern.
- Require two consecutive failed pings before declaring the target dropped to avoid transient packet-loss false positives. - Detect drop across the full POWER_OFF_TIME window so slow-discharging targets are not falsely flagged. - Pi Zero: only setup and restore the relays selected via --relay; do not touch unselected pins. - Drop dead CAM_IPS guard (CAM_IPS always falls back to a default list).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #363 +/- ##
===========================================
+ Coverage 72.74% 73.85% +1.10%
===========================================
Files 6 6
Lines 631 631
===========================================
+ Hits 459 466 +7
+ Misses 172 165 -7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Adds scripts/setup_patrol_presets.py to configure PTZ presets 0-3 via the camera API. Updates ruff per-file-ignores to cover scripts/.
Watchdog and relay_check scripts on both main Pi and Pi Zero need RPi.GPIO; document it so deployment can pip install it.
Point operators at watchdog/requirements.txt so they install RPi.GPIO before running watchdog.py or relay_check.py on either Pi.
RPi.GPIO 0.7.1 has no piwheels wheel for Python 3.13 and fails to compile without python3-dev. rpi-lgpio is a drop-in replacement (same RPi.GPIO API), ships wheels, and works on Pi 5 / kernel 6.x where the legacy package is broken.
Cron runs scripts with /usr/bin/python3, so the GPIO library must be available to system Python. Use python3-rpi-lgpio (Debian package) so no venv or PEP 668 workaround is needed; drop requirements.txt.
Add instructions for the common case where operators only have SSH to the main Pi: launch the test detached on the Pi Zero so the script survives the main Pi rebooting mid-cut, then read /tmp/relay_check.log after reconnect. Also ignore T201/FURB105 under watchdog/ since these CLI scripts intentionally use print().
fe51
left a comment
There was a problem hiding this comment.
Hi @MateoLostanlen, thanks for the PR !
-scripts/setup_patrol_presets.pycould you add common command to run ? (on the main pi I guess)
- For relay_check scripts, one to be launch from ssh main pi and the other one for pi zero, what is the strat ? Access pi zero from wifi seems to be the best strat ?
Also, what are your thoughts on the relay testing protocol?
As relay scripts are supposed to work (and have been tested multiple time); what we want to do now, producting a station, is to verify that the relay devices are functioning correctly and are properly connected under real-world conditions, and that is what this PR does.
From now on, the idea is simply to run these two scripts, isn’t it?