feat: server telemetry, update entity, sync-clock controls

- Server device exposing CPU/RAM/GPU/temperature/battery sensors via
  /api/v1/system/performance, plus last-restart timestamp (cached with
  jitter threshold so the recorder doesn't see poll wobble) and version.
- Update entity backed by /api/v1/system/update — installs via
  /apply, hides the install button when the server reports
  can_auto_update=false.
- Sync-clock entities: reset button, speed number, running switch, and
  the event listener now refreshes on entity_changed events too.
- Bump manifest to 0.4.0.
This commit is contained in:
2026-04-27 01:35:42 +03:00
parent e8f2b5e528
commit a666d9eb9c
12 changed files with 1080 additions and 23 deletions
+60
View File
@@ -32,6 +32,9 @@ async def async_setup_entry(
if source.get("source_type") == "api_input":
entities.append(ApiInputTimeout(coordinator, source, entry.entry_id))
for clock in coordinator.data.get("sync_clocks") or []:
entities.append(SyncClockSpeed(coordinator, clock["id"], entry.entry_id))
if coordinator.data and "targets" in coordinator.data:
devices = coordinator.data.get("devices") or {}
@@ -300,3 +303,60 @@ class ApiInputTimeout(CoordinatorEntity, NumberEntity):
if source.get("id") == self._source_id:
return source
return None
# --- Sync clock number entities ---
class SyncClockSpeed(CoordinatorEntity, NumberEntity):
"""Speed multiplier for a sync clock (server range 0.110.0).
Hot-applied — running animations linked to the clock change pace
immediately without resetting their position.
"""
_attr_has_entity_name = True
_attr_native_min_value = 0.1
_attr_native_max_value = 10.0
_attr_native_step = 0.1
_attr_mode = NumberMode.SLIDER
_attr_icon = "mdi:speedometer"
def __init__(
self,
coordinator: LedGrabCoordinator,
clock_id: str,
entry_id: str,
) -> None:
super().__init__(coordinator)
self._clock_id = clock_id
self._entry_id = entry_id
self._attr_unique_id = f"{clock_id}_speed"
self._attr_translation_key = "sync_clock_speed"
@property
def device_info(self) -> dict[str, Any]:
return {"identifiers": {(DOMAIN, self._clock_id)}}
@property
def native_value(self) -> float | None:
clock = self._get_clock()
if not clock:
return None
speed = clock.get("speed")
return float(speed) if speed is not None else None
@property
def available(self) -> bool:
return self._get_clock() is not None
async def async_set_native_value(self, value: float) -> None:
await self.coordinator.update_sync_clock(self._clock_id, speed=round(value, 2))
def _get_clock(self) -> dict[str, Any] | None:
if not self.coordinator.data:
return None
for clock in self.coordinator.data.get("sync_clocks", []):
if clock.get("id") == self._clock_id:
return clock
return None