Skip to content

Wave 2 #28 (replay): Networking controls (VP2430) via OpenWrt API — Controls tab + Restart safety guard - #98

Open
bernardc6 wants to merge 1 commit into
mainfrom
feat/wave2-networking-controls-clean
Open

Wave 2 #28 (replay): Networking controls (VP2430) via OpenWrt API — Controls tab + Restart safety guard#98
bernardc6 wants to merge 1 commit into
mainfrom
feat/wave2-networking-controls-clean

Conversation

@bernardc6

Copy link
Copy Markdown
Collaborator

Wave 2 #28: Networking controls (VP2430) via OpenWrt API — Controls tab + Restart safety guard

Adds an operator-facing Controls tile to the RoamCore Network page. The slice ships the same intent as the original PR #31 (ebc87d8, opened 2026-07-29) but rebased cleanly onto current main so it's actually mergeable.

Why a new branch instead of fixing PR #31: the original branch was forked from an old main (609b85a, pre-Wave 2 #23-#27 stack) and is now 76 commits behind. The slice itself is fully additive (no cross-cutting rewrites) so the cleanest fix is one fresh commit on current main. This PR supersedes #31.

What's in it

File Change
homeassistant/packages/roamcore_openwrt_api.yaml +50 — input_boolean.rc_confirm_offline (defaults OFF) + template.binary_sensor.rc_setup_networking_safe (online AND opt-in)
homeassistant/www/roamcore/roamcore-pages.js +110 — Network page gains a Controls tile: 3 preference buttons (Starlink/LTE/Auto) wired to script.rc_openwrt_prefer_{starlink,lte,auto}; Restart Network button disabled by default; native <dialog> one-tap confirmation
scripts/checks/openwrt-controls-smoke.sh +162 (NEW) — 10 static assertions covering the slice; already wired into scripts/check.sh via run_if_present at line 67
docs/feature-checklist.md +1/-1 — line 69 ticked
docs/mvp/features-build-status.md +8 — Row #28 under Shipped (repo)

Total: 5 files / +331 / -1.

Acceptance criteria

  1. ✅ Operator can switch WAN preference between Starlink / LTE / Auto via the Network page; the active preference is rendered disabled + ✓.
  2. ✅ Restart Network button is locked by default (rc_confirm_offline=off); operator must opt in to unlock it.
  3. ✅ When unlocked, the Restart button fires a native <dialog> ("Restart the network? Connected clients will drop for ~30 s.") before invoking script.rc_openwrt_restart_network — no surprise reboots.
  4. bash scripts/checks/openwrt-controls-smoke.sh → 10/10 PASS.
  5. bash scripts/check.sh --core-only → exit 0 (no regressions across 21+ connection manifests + ha-beta-smoke + imagebuilder-smoke + docs-link-integrity).
  6. ✅ Tier discipline: tier-a native (RoamCore owns the script + template + UI wiring). No tier-letter exposure in user copy.
  7. ✅ Plain-English error copy: <dialog> body says "Connected clients will drop for ~30 s" — not "ubus netifd restart failure".
  8. ✅ Idempotent: re-applying produces the same end state — no migrations, no state files, no coordination.
  9. ✅ No secrets, no API tokens, no external calls. CSP-friendly addEventListener wiring (no inline onclick).
  10. ✅ JS pattern preserved: re-uses _tile(), _header(), _badge(), _row(), _getState(), _isOn(); no new layout primitives.

Out of scope (separate slices)

Rollback

gh pr close <num> (or revert after merge). The slice is fully additive — removing the Controls tile + the input_boolean + the template sensor + the smoke leaves the repo in its prior state; no HA-side data needs cleanup.

…ab + Restart safety guard

Context
=======
PR #31 was opened on 2026-07-29 with this exact slice but branched off
an old main (609b85a) that pre-dated the Wave 2 #23-#27 stack. The
branch fell 76 commits behind main and became unmergeable in its
original form.

This commit replays the same slice as a single additive commit onto
current main (d3d596b) so PR #31 can be replaced and the slice can
finally ship. Operators land on the Network page, see a Controls tile,
and can switch the WAN preference or restart the network — guarded by
a native <dialog> confirmation that only unlocks when the OpenWrt API
reports internet online AND the operator has opted in via
input_boolean.rc_confirm_offline.

Changes (5 files, +323/-1)
==========================
1. homeassistant/packages/roamcore_openwrt_api.yaml (+50)
   - input_boolean.rc_confirm_offline (initial: off)
   - template.binary_sensor.rc_setup_networking_safe =
       (sensor.rc_openwrt_internet == 'online')
       AND (input_boolean.rc_confirm_offline == 'on')
     with proper availability guard.

2. homeassistant/www/roamcore/roamcore-pages.js (+110)
   - RoamcoreNetworkPage._render() gains a Controls tile:
     * 3 preference buttons (Starlink / LTE / Auto) wired to
       script.rc_openwrt_prefer_{starlink,lte,auto}; the button
       matching sensor.rc_openwrt_active_wan is rendered disabled
       and styled as the current preference.
     * Restart Network button — rendered disabled unless
       binary_sensor.rc_setup_networking_safe is on.
     * Native <dialog> one-tap confirmation before firing
       script.rc_openwrt_restart_network ("Restart the network?
       Connected clients will drop for ~30 s.").
   - Event handlers bound with addEventListener (CSP-friendly).

3. scripts/checks/openwrt-controls-smoke.sh (+162, new)
   - Purely static smoke. Asserts:
     * all 4 scripts declared with their documented alias
     * input_boolean.rc_confirm_offline defaults off
     * template.binary_sensor.rc_setup_networking_safe present with
       documented formula
     * Controls tile references all 4 script entity ids
     * Restart confirmation uses <dialog> element
     * Restart button disabled when guard is off
   - Wired into scripts/check.sh via run_if_present at line 67.

4. docs/feature-checklist.md (+1/-1)
   - Line 69: [ ] Networking controls (VP2430) via OpenWrt API
     → [x] ... (slice #28, with a back-link to the slice).

5. docs/mvp/features-build-status.md (+8)
   - Row #28 added under "Shipped (repo)":
     HA package + 4 scripts + safety guard + UI tile + smoke + branch.

Verification
============
1. bash scripts/checks/openwrt-controls-smoke.sh
   → All 10 assertions PASS.

2. bash scripts/check.sh --core-only
   → exit 0 (all 21+ connection manifests + ha-beta-smoke +
     openwrt-controls-smoke + imagebuilder-smoke + docs-link-integrity
     pass).

3. JS pattern preserved: re-uses _tile(), _header(), _badge(), _row(),
   _getState(), _isOn(); no new layout primitives; no new inline
   onclick handlers (CSP-friendly addEventListener binding).

4. Tier discipline: HA package additions are tier-a native (RoamCore
   owns the script + template + UI wiring); user-facing doc updated
   without exposing internal protocol details.

5. Plain-English errors: the <dialog> copy says "Connected clients
   will drop for ~30 s" not "OpenWrt ubus call netifd restart failed".

6. Idempotent: re-applying the slice produces the same end state —
   no migrations, no state files, no coordination required.

Rollback
========
- gh pr close 31 (or revert after merge); the slice is fully
  additive — removing the Controls tile + the input_boolean + the
  template sensor + the smoke leaves the repo in its prior state;
  no HA-side data needs cleanup.

Out of scope (separate slices)
==============================
- Persistent audit log of preference + restart actions (Gate D).
- Active WAN failover policies beyond manual preference selection.
- Wave 2 #29 cloud/Tailscale/remote-access surface.

Supersedes
==========
PR #31 (ebc87d8) — that PR branched off stale main; the slice
itself is preserved verbatim here on current main. The push of this
branch will close PR #31 and open PR #<new>.
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