Skip to content

feat: add end-to-end relay test scripts for both Pis#363

Open
MateoLostanlen wants to merge 10 commits intodevelopfrom
feat/relay-test-scripts
Open

feat: add end-to-end relay test scripts for both Pis#363
MateoLostanlen wants to merge 10 commits intodevelopfrom
feat/relay-test-scripts

Conversation

@MateoLostanlen
Copy link
Copy Markdown
Member

  • 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
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.85%. Comparing base (15dd831) to head (7b5dce3).

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     
Flag Coverage Δ
unittests 73.85% <ø> (+1.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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 fe51 mentioned this pull request Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant