Restart modem: pause Smart Power auto power-cycle until the modem is back
Lint / JS (eslint) (push) Successful in 14s
Lint / Python (flake8) (push) Successful in 1m5s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m13s
Lint / Python (flake8) (pull_request) Successful in 1m14s
Test / Python Tests (pytest) (push) Successful in 1m51s
Security / Python Security (bandit) (pull_request) Successful in 1m25s
Lint / JS (eslint) (pull_request) Successful in 19s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Test / Python Tests (pytest) (pull_request) Successful in 1m32s

UniFi Smart Power on the RPDU's modem outlet saw the internet down while
the modem rebooted and cut its power mid-boot: once during the 11-20
restart and twice after the 11-24 AT&T-app reboot. UniFi only exposes
auto power-cycle as on or off, so the button now turns it off for every
outlet that has it on, and the monitor turns it back on when the restart
ends (back, or after 30 minutes).

- UnifiClient.auto_power_cycle_outlets / set_auto_power_cycle: sends the
  device's outlet_overrides back with only cycle_enabled changed, then
  reads them again to confirm. The only UniFi setting Gandalf changes.
- A failed pause doesn't stop the restart; a failed restart turns it back
  on. A failed restore is retried every cycle and shown as broken in
  Needs attention until it works.
- The panel note and confirm text mention the pause.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-24 00:13:46 -05:00
1 parent a7792063ba
commit a5d4fc3156
9 files changed
+304 -19

No files matched your search

+18 -3
View File
@@ -188,21 +188,36 @@ def _wan(quality: Optional[dict], now: float, checks: Optional[dict] = None) ->
return out
def _smart_power(restart: Optional[dict]) -> List[dict]:
"""Auto power-cycle left off after a modem restart: the modem would not be
power-cycled if it hangs, so this is broken until Gandalf manages to turn it back on."""
r = restart or {}
if not r.get('finished_at') or not r.get('smart_power_paused') or r.get('smart_power_restored'):
return []
outlets = ', '.join(f'{o.get("device")} outlet {o.get("index")}' for o in r['smart_power_paused'])
return [_entry('broken', 'bad', 'Smart Power auto power-cycle is still off after the modem restart',
'#modem-section', f'{outlets}. Gandalf keeps trying to turn it back on'
+ (f' (last error: {r["smart_power_error"]})' if r.get('smart_power_error') else '')
+ '; it can also be turned on in UniFi under the outlet\'s settings.')]
def build(events: List[dict], power: List[dict], cutsheet_view: Optional[dict],
rack_issues: Optional[Dict[str, dict]] = None, wan_quality: Optional[dict] = None,
now: Optional[float] = None, modem_checks: Optional[dict] = None) -> dict:
now: Optional[float] = None, modem_checks: Optional[dict] = None,
modem_restart: Optional[dict] = None) -> dict:
"""{'broken': [entry], 'tidy': [entry]}, worst first within each group.
events: active alerts, annotated with 'is_suppressed'. power: topology.build_power output.
cutsheet_view: the cutsheet API view (cables with 'problem', suggestions, port_names,
labels), or None when the cutsheet couldn't be loaded. rack_issues: {rack: rack_layout()}.
wan_quality: modem.wan_quality() output as stored by the monitor. modem_checks: the
monitor's logged-in modem checks (NAT sessions, ping from the modem). now: for tests.
monitor's logged-in modem checks (NAT sessions, ping from the modem). modem_restart: the
Restart modem button's state, for auto power-cycle left off. now: for tests.
Entry: {group, severity: bad|warn|info, text, href, detail}.
"""
now = time.time() if now is None else now
entries = (_wan(wan_quality, now, modem_checks) + _modem_checks(modem_checks)
+ _alerts(events) + _power(power))
+ _smart_power(modem_restart) + _alerts(events) + _power(power))
if cutsheet_view is not None:
entries += _cutsheet(cutsheet_view)
entries += _rack(rack_issues or {})