Panels become devices: per-device documents in the flow repo, a Devices tab

- flow/devices.py: DeviceDef in FLOWS_DIR/_devices/<id>.json, committed under
  the flow store's write lock, 409 on a stale version; nonces in DEVICES_FILE
  outside git; in-memory presence announced as device_status
- api/routes/devices.py: CRUD, pairing with an optional {name, board,
  firmware}, a pending list adopted without a code from the LAN only, unpair;
  /panels/pair, /panels/pair/{code} and GET /panels/{id} kept as aliases,
  PUT /panels/ gone
- _device_may replaces _panel_may, JWT claims unchanged
- panels.json moves into devices once at startup, then .migrated
- MCP list_devices, get_device; search category device
- Devices tab (list, detail with presence, pairing, ordered dashboards,
  touch, I/O), PanelsDialog removed, serialised optimistic saves

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Melvin Strobl
2026-10-16 15:48:36 +02:00
co-authored by Claude Opus 5.5
parent 01495aed25
commit ed06bdec6b
56 changed files with 3539 additions and 2404 deletions
+12 -19
View File
@@ -10,10 +10,9 @@ from pathlib import Path
import pytest
from fluksio.api.routes.flows import _endpoints
from fluksio.core.config import settings
from fluksio.flow.controller import FlowController
from fluksio.flow.devices import DeviceDef, DevicePort, DeviceStore
from fluksio.flow.messages import DType, MessageSpec
from fluksio.flow.panels import PanelDef, PanelPort, PanelsConfig, write_config
from fluksio.flow.schemas import FlowDef, NodeDef
from fluksio.flow.store import FlowStore
@@ -113,23 +112,17 @@ def test_the_wiring_index_is_read_once_per_store_revision(controller):
assert reads == 2
def test_a_panel_port_is_drawn_on_the_side_it_wires(controller, tmp_path, monkeypatch):
monkeypatch.setattr(settings, "PANELS_FILE", tmp_path / "panels.json")
write_config(
PanelsConfig(
panels=[
PanelDef(
id="hall",
title="Hall",
io=[
PanelPort(port="gpio.4", message="house.temp", direction="in"),
PanelPort(
port="backlight", message="house.temp", direction="out"
),
PanelPort(port="mic", message="garage.open", direction="in"),
],
)
]
def test_a_device_port_is_drawn_on_the_side_it_wires(controller, tmp_path):
controller.devices = DeviceStore(controller.store, tmp_path / "devices.json")
controller.devices.create(
DeviceDef(
id="hall",
title="Hall",
io=[
DevicePort(port="gpio.4", message="house.temp", direction="in"),
DevicePort(port="backlight", message="house.temp", direction="out"),
DevicePort(port="mic", message="garage.open", direction="in"),
],
)
)