Capability report: PUT /devices/{id}/report, a Capabilities section, offline devices degraded
A device reports its board, screen, camera and ports from its own credential (16 KB, schema 1, replacing the last report), and the flows are validated against it again. The node panel turns a reported port's config schema into a form, a reported screen is a canvas preset and a touch screen's first report turns Touch friendly on. An offline device node is degraded: amber on the canvas, a warning on Home, never a fault.
This commit is contained in:
@@ -53,6 +53,8 @@ def _epoch(column: Any) -> ColumnElement[int]:
|
||||
class HealthSummary(BaseModel):
|
||||
status: str
|
||||
problems: list[str]
|
||||
#: Worth a look, but not faults: they leave ``status`` as it is.
|
||||
warnings: list[str] = []
|
||||
flows: dict[str, int]
|
||||
nodes: dict[str, int]
|
||||
queue: dict[str, Any]
|
||||
@@ -241,9 +243,24 @@ async def read_summary(request: Request, controller: FlowControllerDep) -> Any:
|
||||
if invalid:
|
||||
problems.append(f"{len(invalid)} flow(s) cannot run: {', '.join(invalid)}")
|
||||
|
||||
# Working, if not as well as they should: a device switched off, a send
|
||||
# queue full. A warning, held back by the same floor as `unhealthy`.
|
||||
degraded = controller.unhealthy_nodes(health="degraded")
|
||||
warnings = (
|
||||
[
|
||||
f"{len(degraded)} node(s) degraded: "
|
||||
+ ", ".join(
|
||||
sorted(f"{e.id} ({e.health_detail or 'no detail'})" for e in degraded)
|
||||
)
|
||||
]
|
||||
if degraded
|
||||
else []
|
||||
)
|
||||
|
||||
return HealthSummary(
|
||||
status="degraded" if problems else "ok",
|
||||
problems=problems,
|
||||
warnings=warnings,
|
||||
flows={
|
||||
"total": len(names),
|
||||
# What the engine will actually act on. Enabled is not enough:
|
||||
@@ -267,6 +284,7 @@ async def read_summary(request: Request, controller: FlowControllerDep) -> Any:
|
||||
"total": len(entries),
|
||||
"error": len(errored),
|
||||
"unhealthy": len(unhealthy),
|
||||
"degraded": len(degraded),
|
||||
"failing": len(failing),
|
||||
},
|
||||
queue=queue,
|
||||
|
||||
Reference in New Issue
Block a user