feat(homeassistant): it shows system problems and installs updates on a weekly slot, and leaves device readings alone (#6748, #6749, #6747)
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 1m37s
CI / integration (push) Failing after 1m54s
CI / publish (push) Skipped

The connection's job is keeping Home Assistant running. Each poll now reads open
repairs, Supervisor health, disk, recovery mode and add-ons that should be running
over its websocket, for the page, the overview and the problems_open, disk_free_pct
and update_failed metrics. That needs a websocket client, so websockets joins the
dependencies.

A weekly slot, set on the page or through MCP and off until then, installs add-ons,
then Core, then the OS, each after its own confirmed backup, ending at the first
failure. The slot arithmetic moves from the host agent's cadence to steward.core.weekly
so both share it.

The device scrape goes: the page's Metrics section and a target's token_from from
4c9ed02 are removed, and a migration deletes targets using it, as they'd otherwise ask
with no token. A refused token still stops a scrape.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-01 14:16:42 -05:00
co-authored by Claude Opus 5.5
parent 4c9ed02652
commit f7a856cb90
31 changed files with 835 additions and 503 deletions
+21 -2
View File
@@ -3,7 +3,7 @@ from __future__ import annotations
from datetime import datetime, timezone
from sqlalchemy import JSON, Boolean, DateTime, Index, String, Text, text
from sqlalchemy import JSON, Boolean, DateTime, Index, Integer, String, Text, text
from sqlalchemy.orm import Mapped, mapped_column
from steward.core.ids import time_ordered_id
@@ -17,7 +17,7 @@ class HomeAssistantConnection(Base):
has the same access as the user who signed in, whatever that is: Home
Assistant has no narrower permission. `can_install` is whether that user was
an administrator, which backups need. The last_* columns and `updates` and
`backup` are the newest poll's outcome, which the pages read. `refused` stops
`backup` and `health` are the newest poll's outcome, which the pages read. `refused` stops
all polling until someone signs in again or tries again: Home Assistant bans
an address after a few refused requests.
"""
@@ -37,6 +37,25 @@ class HomeAssistantConnection(Base):
last_error: Mapped[str | None] = mapped_column(Text, nullable=True)
updates: Mapped[list] = mapped_column(JSON, nullable=False, default=list)
backup: Mapped[dict] = mapped_column(JSON, nullable=False, default=dict)
health: Mapped[dict] = mapped_column(JSON, nullable=False, default=dict)
class HomeAssistantSchedule(Base):
"""The weekly slot for installing what's waiting; at most one row, none until an
admin sets it. `last_slot_at` is the slot that last fired, and `stopped` says why
that slot ended early. Times are read through steward.core.weekly."""
__tablename__ = "homeassistant_schedule"
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=time_ordered_id)
enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
weekday: Mapped[int] = mapped_column(Integer, nullable=False)
at_time: Mapped[str] = mapped_column(String(5), nullable=False)
time_zone: Mapped[str] = mapped_column(String(64), nullable=False)
window_minutes: Mapped[int] = mapped_column(Integer, nullable=False)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), nullable=False, default=lambda: datetime.now(timezone.utc))
last_slot_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
stopped: Mapped[str | None] = mapped_column(Text, nullable=True)
class HomeAssistantUpdate(Base):