Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion watchdog/shelly/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ python3 watchdog/shelly/check_station.py --cycle-pi # Pi or PC
Trigger the Shelly watchdog for real: stop the `/health` service and wait
3 check intervals (~30 min) — the Shelly must cut outputs 0 and 1 for 2 min.
To speed it up, temporarily re-upload `watchdog.js` with a short
`CHECK_INTERVAL_MS`, then restore it with `update_shelly_watchdog.sh`.
`CHECK_INTERVAL_MS`, then restore it with `setup_shelly_watchdog.sh` from
pyro-sys-setup.

Exit code is non-zero if any check fails.
4 changes: 2 additions & 2 deletions watchdog/shelly/check_station.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def check_shelly(shelly_ip: str) -> str | None:
scripts = (rpc_optional(shelly_ip, "Script.List") or {}).get("scripts", [])
match = [s for s in scripts if s.get("name") == SCRIPT_NAME]
if not match:
ko(f"no script named {SCRIPT_NAME} on the device (run setup_shelly_watchdog.sh)")
ko(f"no script named {SCRIPT_NAME} on the device (run setup_shelly_watchdog.sh from pyro-sys-setup)")
else:
script = match[0]
if script.get("enable"):
Expand Down Expand Up @@ -240,7 +240,7 @@ def check_shelly(shelly_ip: str) -> str | None:
else:
ko(
f"output {out_id} initial_state is {config.get('initial_state')!r}, "
"expected 'on' (run harden_shelly.sh)"
"expected 'on' (run harden_shelly.sh from pyro-sys-setup)"
)

# hardening (warn-level: the watchdog works without it)
Expand Down
4 changes: 0 additions & 4 deletions watchdog/shelly/device/.gitignore

This file was deleted.

60 changes: 9 additions & 51 deletions watchdog/shelly/device/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Shelly Pi watchdog

This setup installs a Shelly script on a Shelly Pro device (works with any Pro
model that exposes the scripting RPC API, e.g. Pro 2PM, Pro 4PM).
`watchdog.js` runs on a Shelly Pro device (works with any Pro model that
exposes the scripting RPC API, e.g. Pro 2PM, Pro 4PM).

It is the Shelly side of the Shelly-based watchdog. The Pi side lives in
`../main_pi/watchdog.py` and power-cycles output 0 when the internet or the
Expand Down Expand Up @@ -47,57 +47,15 @@ Make sure the Shelly is not powered by one of the outputs it cuts.

## Setup procedure

### 1. Put the Shelly on the network
### 1. Set up the Shelly

Power the Shelly, then use the **Shelly Smart Control** app (iOS / Android):
Provisioning (Wi-Fi, static IP, firmware, hardening) and uploading
`watchdog.js` are done from
[pyro-sys-setup](https://github.com/pyronear/pyro-sys-setup#shelly-setup),
which reads `watchdog.js` from a pyro-engine checkout. After changing
`watchdog.js`, upload it again with `setup_shelly_watchdog.sh` from there.

- The app connects to the device over **Bluetooth**.
- Add the device and configure it to join your local **Wi-Fi** (station mode).
- Give it a fixed address (static IP on the device, or a DHCP reservation on the
router) so the watchdog can always reach it. The examples here assume
`192.168.1.97`.

Check it is reachable from the machine that will run the scripts:

```bash
curl "http://192.168.1.97/rpc/Shelly.GetDeviceInfo"
```

### 2. Harden the Shelly

The Shelly is dedicated to running the watchdog, so disable everything else
with `harden_shelly.sh` (Cloud, MQTT, outbound WebSocket, Wi-Fi access point,
BLE, and any webhooks/schedules), enable eco mode to reduce heat, and force the
watchdog outputs (0 and 1) to power on at boot so a Shelly restart does not
leave the Pi unpowered:

```bash
cd watchdog/shelly/device
chmod +x harden_shelly.sh setup_shelly_watchdog.sh update_shelly_watchdog.sh
SHELLY_IP="192.168.1.97" ./harden_shelly.sh
```

After this the Shelly is only reachable over your main Wi-Fi (station mode), so
make sure step 1 worked first. If that link is later lost you need the physical
reset button to bring the access point back.

### 3. Install the Shelly watchdog script

Upload and start `watchdog.js` on the Shelly:

```bash
SHELLY_IP="192.168.1.97" ./setup_shelly_watchdog.sh
```

This is the Shelly side: it polls the Pi `/health` endpoint and reboots outputs
0 and 1 if the Pi is unhealthy. To change the target URL or timings, edit
`watchdog.js` and re-run:

```bash
SHELLY_IP="192.168.1.97" ./update_shelly_watchdog.sh
```

### 4. Install the Pi-side watchdog
### 2. Install the Pi-side watchdog

The Pi side (`../main_pi/watchdog.py`) covers the other direction: it checks
internet connectivity and the cameras, and asks the Shelly to power-cycle
Expand Down
138 changes: 0 additions & 138 deletions watchdog/shelly/device/harden_shelly.sh

This file was deleted.

85 changes: 0 additions & 85 deletions watchdog/shelly/device/setup_shelly_watchdog.sh

This file was deleted.

67 changes: 0 additions & 67 deletions watchdog/shelly/device/update_shelly_watchdog.sh

This file was deleted.

Loading