Self-hosted homelab infrastructure visualizer — interactive network diagram with live status monitoring
TypeScript diagramhomelabhomelab-infrastructure-observabilitynetworkproxmox-veself-hostedzigbeezwavezwave-js
feat(zigbee): carry LQI on the link and import mesh links on demand
Pouzor1bd89bed6b5e
diff --git a/backend/app/api/routes/scan.py b/backend/app/api/routes/scan.pyindex 12cd5a2..e6b5c84 100644--- a/backend/app/api/routes/scan.py+++ b/backend/app/api/routes/scan.py@@ -1081,6 +1081,10 @@ async def _resolve_pending_links_for_ieee(edge_type, src_handle, tgt_handle = "virtual", "bottom", "top"elif link.discovery_source == "proxmox_cluster":edge_type, src_handle, tgt_handle = "cluster", "right", "left"+ elif link.discovery_source == "zigbee_mesh":+ # Neighbour link, not a parent attachment: sideways, like the+ # cluster edges, so it reads apart from the tree.+ edge_type, src_handle, tgt_handle = "zigbee_mesh", "right", "left"else:edge_type, src_handle, tgt_handle = "iot", "bottom", "top"edge = Edge(diff --git a/backend/app/api/routes/zigbee.py b/backend/app/api/routes/zigbee.pyindex 23bed90..953b041 100644--- a/backend/app/api/routes/zigbee.py+++ b/backend/app/api/routes/zigbee.py@@ -125,6 +125,7 @@ async def _background_canvas_import(job_id: str, payload: ZigbeeImportRequest) -password=payload.mqtt_password,tls=payload.mqtt_tls,tls_insecure=payload.mqtt_tls_insecure,+ include_mesh_links=payload.include_mesh_links,)except Exception as exc:status, detail = _import_error(exc)@@ -192,6 +193,9 @@ def env_import_request() -> ZigbeeImportRequest:base_topic=settings.zigbee_base_topic,mqtt_tls=settings.zigbee_mqtt_tls,mqtt_tls_insecure=settings.zigbee_mqtt_tls_insecure,+ # The scheduled auto-sync keeps the readable parent tree. Importing the+ # full mesh is a deliberate, per-import choice made in the UI.+ include_mesh_links=False,)@@ -236,6 +240,7 @@ async def _background_zigbee_import(run_id: str, payload: ZigbeeImportRequest) -password=payload.mqtt_password,tls=payload.mqtt_tls,tls_insecure=payload.mqtt_tls_insecure,+ include_mesh_links=payload.include_mesh_links,)result = await _persist_pending_import(db, nodes_raw, edges_raw)run = await db.get(ScanRun, run_id)@@ -334,7 +339,11 @@ async def _persist_pending_import(# Replace all zigbee-source links with the freshly discovered set.await db.execute(- sa_delete(InventoryDeviceLink).where(InventoryDeviceLink.discovery_source == "zigbee")+ sa_delete(InventoryDeviceLink).where(+ # Both sources, or mesh links would pile up import after import:+ # the wipe below is what keeps this a replace, not an append.+ InventoryDeviceLink.discovery_source.in_(["zigbee", "zigbee_mesh"])+ ))links_recorded = 0@@ -349,7 +358,12 @@ async def _persist_pending_import(InventoryDeviceLink(source_ieee=src,target_ieee=tgt,- discovery_source="zigbee",+ lqi=e.get("lqi"),+ # A neighbour link is tagged apart from the parent tree so the+ # canvas can draw it in its own edge type on approval.+ discovery_source=(+ "zigbee_mesh" if e.get("kind") == "mesh" else "zigbee"+ ),))links_recorded += 1diff --git a/backend/app/db/database.py b/backend/app/db/database.pyindex 7bb3560..48ed706 100644--- a/backend/app/db/database.py+++ b/backend/app/db/database.py@@ -375,6 +375,13 @@ async def init_db() -> None:"UPDATE edges SET design_id = ? WHERE design_id IS NULL", (_default_design_id,),)+ # Measured Zigbee link quality. It rides on the edge because that is+ # what it measures — a link, not an endpoint (issue #496).+ await _try_migrate(+ conn, "ALTER TABLE edges ADD COLUMN lqi INTEGER",+ label="edges.lqi",+ )+# Migrate canvas_state from id=1 to design_id PK (SQLite rebuild)try:info = await conn.exec_driver_sql("PRAGMA table_info(canvas_state)")diff --git a/backend/app/db/models.py b/backend/app/db/models.pyindex f54209e..13584c8 100644--- a/backend/app/db/models.py+++ b/backend/app/db/models.py@@ -93,6 +93,10 @@ class Edge(Base):label: Mapped[str | None] = mapped_column(String)vlan_id: Mapped[int | None] = mapped_column(Integer)speed: Mapped[str | None] = mapped_column(String)+ # Link quality (Zigbee mesh). Measured per link, so it belongs to the edge+ # rather than to either endpoint — see issue #496. Read-only: it is written+ # by the import, never edited by hand, so `EdgeUpdate` deliberately omits it.+ lqi: Mapped[int | None] = mapped_column(Integer, nullable=True)custom_color: Mapped[str | None] = mapped_column(String)path_style: Mapped[str | None] = mapped_column(String)line_style: Mapped[str | None] = mapped_column(String)diff --git a/backend/app/schemas/canvas.py b/backend/app/schemas/canvas.pyindex e1c90cf..739d72a 100644--- a/backend/app/schemas/canvas.py+++ b/backend/app/schemas/canvas.py@@ -89,6 +89,10 @@ class EdgeSave(BaseModel):label: str | None = Nonevlan_id: int | None = Nonespeed: str | None = None+ # Measured link quality (#496). The canvas save path has its own edge+ # schema, so a field added to `EdgeBase` alone would be dropped here and+ # the save would overwrite the stored LQI with NULL.+ lqi: int | None = Nonecustom_color: str | None = Nonepath_style: str | None = Noneline_style: str | None = Nonediff --git a/backend/app/schemas/edges.py b/backend/app/schemas/edges.pyindex 307e120..5aed1e6 100644--- a/backend/app/schemas/edges.py+++ b/backend/app/schemas/edges.py@@ -12,6 +12,10 @@ class EdgeBase(BaseModel):label: str | None = Nonevlan_id: int | None = Nonespeed: str | None = None+ # Measured link quality, written by the Zigbee import. Absent from+ # `EdgeUpdate` on purpose: it is an observation, not a user setting, and an+ # editable copy would be silently overwritten by the next import.+ lqi: int | None = Nonecustom_color: str | None = Nonepath_style: str | None = Noneline_style: str | None = Nonediff --git a/backend/app/schemas/zigbee.py b/backend/app/schemas/zigbee.pyindex e6851ee..95048d2 100644--- a/backend/app/schemas/zigbee.py+++ b/backend/app/schemas/zigbee.py@@ -13,6 +13,14 @@ class ZigbeeImportRequest(BaseModel):mqtt_tls_insecure: bool = Field(False, description="Skip TLS certificate verification (self-signed only)")+ include_mesh_links: bool = Field(+ False,+ description=(+ "Also import neighbour-to-neighbour mesh links, not just the "+ "parent tree. Off by default: it turns a ~36-edge map into ~115 "+ "on a 37-device network."+ ),+ )@model_validator(mode="after")def _insecure_requires_tls(self) -> "ZigbeeImportRequest":@@ -69,6 +77,12 @@ class ZigbeeNodeOut(BaseModel):class ZigbeeEdgeOut(BaseModel):source: strtarget: str+ # Link quality for this link. It lives on the edge because that is what it+ # measures — a radio link between two devices, not a property of either.+ lqi: int | None = None+ # "tree" = the parent attachment drawn by default; "mesh" = a neighbour+ # link, only emitted when the import asked for them.+ kind: str = "tree"class ZigbeeImportResponse(BaseModel):diff --git a/backend/app/services/zigbee_service.py b/backend/app/services/zigbee_service.pyindex 085ee2b..23d5aa1 100644--- a/backend/app/services/zigbee_service.py+++ b/backend/app/services/zigbee_service.py@@ -120,6 +120,7 @@ def _node_from_z2m(raw: dict[str, Any]) -> dict[str, Any] | None:def parse_networkmap(payload: dict[str, Any],+ include_mesh_links: bool = False,) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]:"""Parse a Z2M ``bridge/response/networkmap`` payload into node + edge lists.@@ -170,13 +171,13 @@ def parse_networkmap(coordinator_id = node["id"]# Z2M `links` is bidirectional/mesh: every pair appears twice and routers- # carry sibling-mesh paths. Walk it only to extract LQI per device and to+ # carry sibling-mesh paths. Walk it only to extract LQI per link and to# resolve which router an end device hangs off; do NOT emit edges directly# from links. The final edge set is the strict parent→child tree built# from parent_id below — that avoids duplicate edges and keeps the visual# flow consistent (parent bottom → child top).raw_edges: list[dict[str, Any]] = []- lqi_by_id: dict[str, int] = {}+ lqi_by_pair: dict[tuple[str, str], int] = {}for link in raw_links:if not isinstance(link, dict):@@ -190,13 +191,20 @@ def parse_networkmap(if src not in seen_ids or tgt not in seen_ids:continueraw_edges.append({"source": src, "target": tgt})- lqi = link.get("lqi") or link.get("linkquality")- if isinstance(lqi, int) and tgt not in lqi_by_id:- lqi_by_id[tgt] = lqi-- for node in nodes_list:- if node["id"] in lqi_by_id:- node["lqi"] = lqi_by_id[node["id"]]+ # LQI belongs to the *link*, never to one endpoint. Z2M emits+ # neighbour -> reporting device, so keying it by either side attributes+ # a neighbour's measurement to a device — and leaves every EndDevice at+ # None, since a sleepy device keeps no neighbour table and is therefore+ # never a target. Keep it per ordered pair; project it below.+ # A falsy `or` would swallow a legitimate lqi == 0 (a dead link, and the+ # most interesting value of all), so test for None explicitly.+ lqi = link.get("lqi")+ if lqi is None:+ lqi = link.get("linkquality")+ if isinstance(lqi, int):+ pair = (src, tgt)+ previous = lqi_by_pair.get(pair)+ lqi_by_pair[pair] = lqi if previous is None else max(previous, lqi)# Build parent_id hierarchy: coordinator → routers → end devicesif coordinator_id:@@ -208,13 +216,53 @@ def parse_networkmap(parent = _find_parent_router(node["id"], router_ids, raw_edges)node["parent_id"] = parent or coordinator_id+ # A device's LQI is a *projection* of the link to its parent, reported in+ # whichever direction Z2M measured it. Deterministic, unlike "whichever+ # neighbour happened to be listed first".+ for node in nodes_list:+ parent = node.get("parent_id")+ if not parent:+ continue+ lqi = _link_lqi(lqi_by_pair, node["id"], parent)+ if lqi is not None:+ node["lqi"] = lqi+# Final edges = strict parent → child tree (one edge per non-coordinator)edges_list: list[dict[str, Any]] = [- {"source": node["parent_id"], "target": node["id"]}+ {+ "source": node["parent_id"],+ "target": node["id"],+ "lqi": node.get("lqi"),+ "kind": "tree",+ }for node in nodes_listif node.get("parent_id")]+ # Opt-in: also emit the neighbour links the tree drops. Off by default —+ # a 37-device mesh turns ~36 tree edges into 115, which is unreadable+ # unless the user asked for it.+ if include_mesh_links:+ tree_pairs = {_pair_key(e["source"], e["target"]) for e in edges_list}+ seen_mesh: set[tuple[str, str]] = set()+ for edge in raw_edges:+ src, tgt = edge["source"], edge["target"]+ pair = _pair_key(src, tgt)+ # Z2M reports each link once per endpoint that measured it, so the+ # same pair arrives twice — collapse it to one undirected edge, and+ # never duplicate one the parent tree already draws.+ if src == tgt or pair in tree_pairs or pair in seen_mesh:+ continue+ seen_mesh.add(pair)+ edges_list.append(+ {+ "source": src,+ "target": tgt,+ "lqi": _link_lqi(lqi_by_pair, src, tgt),+ "kind": "mesh",+ }+ )+return nodes_list, edges_list@@ -234,6 +282,30 @@ def _find_parent_router(return None+def _link_lqi(+ lqi_by_pair: dict[tuple[str, str], int],+ a: str,+ b: str,+) -> int | None:+ """Best LQI reported for the a<->b link, in either direction.++ Z2M reports a link once per endpoint that keeps a neighbour table, so the+ same physical link can carry two different measurements. Keep the better+ one rather than whichever was parsed first.+ """+ measured = [+ value+ for value in (lqi_by_pair.get((a, b)), lqi_by_pair.get((b, a)))+ if value is not None+ ]+ return max(measured) if measured else None+++def _pair_key(a: str, b: str) -> tuple[str, str]:+ """Undirected key for a link, so A->B and B->A collapse to one edge."""+ return (a, b) if a <= b else (b, a)++async def fetch_networkmap(mqtt_host: str,mqtt_port: int,@@ -243,9 +315,13 @@ async def fetch_networkmap(tls: bool = False,tls_insecure: bool = False,response_timeout: float | None = None,+ include_mesh_links: bool = False,) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]:"""Connect to the MQTT broker, request the Z2M networkmap, and return (nodes, edges).+ ``include_mesh_links`` also emits the neighbour links the parent tree drops;+ see :func:`parse_networkmap`.+``response_timeout`` defaults to ``settings.zigbee_networkmap_timeout``(env ``ZIGBEE_NETWORKMAP_TIMEOUT``, 300 s) — a 200+ device mesh can takeminutes to answer.@@ -325,7 +401,7 @@ async def fetch_networkmap(if not response_payload:raise ValueError("Empty networkmap response received")- return parse_networkmap(response_payload)+ return parse_networkmap(response_payload, include_mesh_links)async def test_mqtt_connection(diff --git a/backend/tests/test_canvas.py b/backend/tests/test_canvas.pyindex 73cef35..d076833 100644--- a/backend/tests/test_canvas.py+++ b/backend/tests/test_canvas.py@@ -83,6 +83,30 @@ async def test_save_canvas_round_trips_line_style_and_width(client: AsyncClient,assert edge["width_mult"] == 3+async def test_save_canvas_round_trips_lqi(client: AsyncClient, headers: dict):+ """LQI rides on the edge (#496) and must survive a save + reload.++ 0 is a real reading — a dead link — not a missing one.+ """+ n1 = node_payload(label="Router", type="router")+ n2 = node_payload(label="Switch", type="switch")+ e1 = edge_payload(n1["id"], n2["id"], type="iot", lqi=0)+ await client.post("/api/v1/canvas/save", json={"nodes": [n1, n2], "edges": [e1], "viewport": {}}, headers=headers)++ edge = (await client.get("/api/v1/canvas", headers=headers)).json()["edges"][0]+ assert edge["lqi"] == 0+++async def test_save_canvas_lqi_defaults_to_none(client: AsyncClient, headers: dict):+ n1 = node_payload(label="Router", type="router")+ n2 = node_payload(label="Switch", type="switch")+ e1 = edge_payload(n1["id"], n2["id"])+ await client.post("/api/v1/canvas/save", json={"nodes": [n1, n2], "edges": [e1], "viewport": {}}, headers=headers)++ edge = (await client.get("/api/v1/canvas", headers=headers)).json()["edges"][0]+ assert edge["lqi"] is None++async def test_save_canvas_coerces_legacy_boolean_marker(client: AsyncClient, headers: dict):n1 = node_payload(label="Router", type="router")n2 = node_payload(label="Switch", type="switch")diff --git a/backend/tests/test_zigbee_router.py b/backend/tests/test_zigbee_router.pyindex 7c88897..9bc7b6c 100644--- a/backend/tests/test_zigbee_router.py+++ b/backend/tests/test_zigbee_router.py@@ -206,6 +206,7 @@ async def test_import_with_credentials(client: AsyncClient, headers: dict) -> Nopassword="secret",tls=False,tls_insecure=False,+ include_mesh_links=False,)@@ -448,6 +449,85 @@ async def test_persist_pending_import_replaces_links(db_session) -> None:assert (rows[0].source_ieee, rows[0].target_ieee) == ("0xCOORD", "0xR1")+async def test_persist_pending_import_records_link_lqi(db_session) -> None:+ """LQI measures the link, so it is stored on the link row (#496)."""+ from sqlalchemy import select++ from app.api.routes.zigbee import _persist_pending_import+ from app.db.models import InventoryDeviceLink++ edges = [+ {"source": "0xCOORD", "target": "0xR1", "lqi": 220},+ {"source": "0xR1", "target": "0xE1", "lqi": 0},+ ]+ await _persist_pending_import(db_session, _PENDING_NODES, edges)++ rows = (await db_session.execute(select(InventoryDeviceLink))).scalars().all()+ by_pair = {(r.source_ieee, r.target_ieee): r.lqi for r in rows}+ assert by_pair[("0xCOORD", "0xR1")] == 220+ # A dead link reads 0 — it must survive as 0, not collapse to NULL.+ assert by_pair[("0xR1", "0xE1")] == 0+++async def test_persist_pending_import_link_lqi_defaults_to_none(db_session) -> None:+ """A map that reported no LQI leaves the column NULL rather than guessing."""+ from sqlalchemy import select++ from app.api.routes.zigbee import _persist_pending_import+ from app.db.models import InventoryDeviceLink++ await _persist_pending_import(db_session, _PENDING_NODES, _PENDING_EDGES)++ rows = (await db_session.execute(select(InventoryDeviceLink))).scalars().all()+ assert rows+ assert all(r.lqi is None for r in rows)+++async def test_persist_pending_import_tags_mesh_links_apart(db_session) -> None:+ """Mesh links carry their own discovery_source so the canvas can style them."""+ from sqlalchemy import select++ from app.api.routes.zigbee import _persist_pending_import+ from app.db.models import InventoryDeviceLink++ edges = [+ {"source": "0xCOORD", "target": "0xR1", "lqi": 200, "kind": "tree"},+ {"source": "0xR1", "target": "0xE1", "lqi": 150, "kind": "mesh"},+ ]+ await _persist_pending_import(db_session, _PENDING_NODES, edges)++ rows = (await db_session.execute(select(InventoryDeviceLink))).scalars().all()+ by_pair = {(r.source_ieee, r.target_ieee): r.discovery_source for r in rows}+ assert by_pair[("0xCOORD", "0xR1")] == "zigbee"+ assert by_pair[("0xR1", "0xE1")] == "zigbee_mesh"+++async def test_persist_pending_import_wipes_mesh_links_too(db_session) -> None:+ """The wipe must cover both sources, or mesh links pile up import on import."""+ from sqlalchemy import select++ from app.api.routes.zigbee import _persist_pending_import+ from app.db.models import InventoryDeviceLink++ with_mesh = [+ {"source": "0xCOORD", "target": "0xR1", "kind": "tree"},+ {"source": "0xR1", "target": "0xE1", "kind": "mesh"},+ ]+ await _persist_pending_import(db_session, _PENDING_NODES, with_mesh)+ # Re-import with the option off: the stale mesh row must be gone, not kept.+ await _persist_pending_import(+ db_session, _PENDING_NODES, [{"source": "0xCOORD", "target": "0xR1", "kind": "tree"}]+ )++ rows = (await db_session.execute(select(InventoryDeviceLink))).scalars().all()+ assert len(rows) == 1+ assert rows[0].discovery_source == "zigbee"++@pytest.mark.asyncioasync def test_persist_pending_import_sets_coordinator_pending_fields(db_session) -> None:"""Coordinator lands in pending carrying its vendor/model metadata."""diff --git a/backend/tests/test_zigbee_service.py b/backend/tests/test_zigbee_service.pyindex 1702379..184e10c 100644--- a/backend/tests/test_zigbee_service.py+++ b/backend/tests/test_zigbee_service.py@@ -187,6 +187,160 @@ class TestParseNetworkmap:end_node = next(n for n in nodes if n["id"] == end)assert end_node["lqi"] == 180+ def test_lqi_attributed_to_enddevice_that_is_never_a_target(self) -> None:+ """Regression for #496.++ Z2M emits links as neighbour -> reporting device. A sleepy EndDevice+ keeps no neighbour table, so it never appears as a ``target`` — keying+ the LQI by the target left every EndDevice at None forever.+ """+ coord = "0x0000"+ end = "0x0001"+ payload = _wrap(+ nodes=[_make_node(coord, "Coordinator"), _make_node(end, "EndDevice")],+ links=[_make_link(end, coord, lqi=110)],+ )+ nodes, _ = parse_networkmap(payload)+ end_node = next(n for n in nodes if n["id"] == end)+ assert end_node["lqi"] == 110++ def test_lqi_zero_is_not_swallowed_by_linkquality(self) -> None:+ """A dead link reads 0 — the most telling value, not a missing one."""+ coord = "0x0000"+ end = "0x0001"+ payload = _wrap(+ nodes=[_make_node(coord, "Coordinator"), _make_node(end, "EndDevice")],+ links=[+ {+ "source": {"ieeeAddr": end},+ "target": {"ieeeAddr": coord},+ "lqi": 0,+ "linkquality": 99,+ }+ ],+ )+ nodes, _ = parse_networkmap(payload)+ end_node = next(n for n in nodes if n["id"] == end)+ assert end_node["lqi"] == 0++ def test_lqi_falls_back_to_linkquality_when_absent(self) -> None:+ coord = "0x0000"+ end = "0x0001"+ payload = _wrap(+ nodes=[_make_node(coord, "Coordinator"), _make_node(end, "EndDevice")],+ links=[+ {+ "source": {"ieeeAddr": end},+ "target": {"ieeeAddr": coord},+ "linkquality": 77,+ }+ ],+ )+ nodes, _ = parse_networkmap(payload)+ end_node = next(n for n in nodes if n["id"] == end)+ assert end_node["lqi"] == 77++ def test_best_of_both_reported_directions_wins(self) -> None:+ """Each endpoint keeping a neighbour table reports the link separately."""+ coord = "0x0000"+ router = "0x0001"+ payload = _wrap(+ nodes=[_make_node(coord, "Coordinator"), _make_node(router, "Router")],+ links=[+ _make_link(coord, router, lqi=120),+ _make_link(router, coord, lqi=200),+ ],+ )+ nodes, _ = parse_networkmap(payload)+ router_node = next(n for n in nodes if n["id"] == router)+ assert router_node["lqi"] == 200++ def test_edges_carry_lqi(self) -> None:+ """LQI rides on the edge: it measures the link, not either endpoint."""+ coord = "0x0000"+ router = "0x0001"+ payload = _wrap(+ nodes=[_make_node(coord, "Coordinator"), _make_node(router, "Router")],+ links=[_make_link(router, coord, lqi=150)],+ )+ _, edges = parse_networkmap(payload)+ assert len(edges) == 1+ assert edges[0]["source"] == coord+ assert edges[0]["target"] == router+ assert edges[0]["lqi"] == 150++ def test_edge_lqi_is_none_when_the_link_was_never_reported(self) -> None:+ coord = "0x0000"+ end = "0x0001"+ payload = _wrap([_make_node(coord, "Coordinator"), _make_node(end, "EndDevice")])+ _, edges = parse_networkmap(payload)+ assert len(edges) == 1+ assert edges[0]["lqi"] is None++ # ── Mesh links (opt-in) ───────────────────────────────────────────────++ def test_mesh_links_are_dropped_by_default(self) -> None:+ """The parent tree stays the default: sibling links are not emitted."""+ coord, r1, r2 = "0x0000", "0x0001", "0x0002"+ payload = _wrap(+ nodes=[+ _make_node(coord, "Coordinator"),+ _make_node(r1, "Router"),+ _make_node(r2, "Router"),+ ],+ links=[_make_link(r1, coord), _make_link(r2, coord), _make_link(r1, r2, lqi=90)],+ )+ _, edges = parse_networkmap(payload)+ assert {(e["source"], e["target"]) for e in edges} == {(coord, r1), (coord, r2)}+ assert all(e["kind"] == "tree" for e in edges)++ def test_mesh_links_emitted_when_requested(self) -> None:+ coord, r1, r2 = "0x0000", "0x0001", "0x0002"+ payload = _wrap(+ nodes=[+ _make_node(coord, "Coordinator"),+ _make_node(r1, "Router"),+ _make_node(r2, "Router"),+ ],+ links=[_make_link(r1, coord), _make_link(r2, coord), _make_link(r1, r2, lqi=90)],+ )+ _, edges = parse_networkmap(payload, include_mesh_links=True)+ mesh = [e for e in edges if e["kind"] == "mesh"]+ assert len(mesh) == 1+ assert frozenset((mesh[0]["source"], mesh[0]["target"])) == frozenset((r1, r2))+ assert mesh[0]["lqi"] == 90++ def test_mesh_links_collapse_both_reported_directions(self) -> None:+ """Z2M reports the pair twice; keep one edge carrying the better LQI."""+ coord, r1, r2 = "0x0000", "0x0001", "0x0002"+ payload = _wrap(+ nodes=[+ _make_node(coord, "Coordinator"),+ _make_node(r1, "Router"),+ _make_node(r2, "Router"),+ ],+ links=[+ _make_link(r1, coord),+ _make_link(r2, coord),+ _make_link(r1, r2, lqi=90),+ _make_link(r2, r1, lqi=140),+ ],+ )+ _, edges = parse_networkmap(payload, include_mesh_links=True)+ mesh = [e for e in edges if e["kind"] == "mesh"]+ assert len(mesh) == 1+ assert mesh[0]["lqi"] == 140++ def test_mesh_links_never_duplicate_a_tree_edge(self) -> None:+ coord, r1 = "0x0000", "0x0001"+ payload = _wrap(+ nodes=[_make_node(coord, "Coordinator"), _make_node(r1, "Router")],+ links=[_make_link(r1, coord), _make_link(coord, r1)],+ )+ _, edges = parse_networkmap(payload, include_mesh_links=True)+ assert len(edges) == 1+ assert edges[0]["kind"] == "tree"+def test_definition_model_and_vendor_extracted(self) -> None:payload = _wrap([_make_node("0xAA", "EndDevice", "Sensor", model="WSDCGQ11LM", vendor="Aqara"),@@ -234,7 +388,7 @@ class TestParseNetworkmap:],)_, edges = parse_networkmap(payload)- assert edges == [{"source": coord, "target": router}]+ assert edges == [{"source": coord, "target": router, "lqi": 200, "kind": "tree"}]def test_router_mesh_siblings_dropped(self) -> None:"""Router↔router mesh paths in `links` must NOT produce sibling edges@@ -269,7 +423,8 @@ class TestParseNetworkmap:_, edges = parse_networkmap(payload)# No edge should target the coordinatorassert all(e["target"] != coord for e in edges)- assert edges == [{"source": coord, "target": end}]+ # The back-edge's LQI still lands on the edge that is kept.+ assert edges == [{"source": coord, "target": end, "lqi": 200, "kind": "tree"}]# ---------------------------------------------------------------------------diff --git a/docs/zigbee-import.md b/docs/zigbee-import.mdindex e55a6d7..1228374 100644--- a/docs/zigbee-import.md+++ b/docs/zigbee-import.md@@ -12,8 +12,15 @@ This feature lets you connect Homelable to your MQTT broker, fetch the Zigbee2MQ- `zigbee_router` — Mains-powered router devices- `zigbee_enddevice` — Battery-powered end devices (sensors, bulbs, etc.)- **Hierarchy** — `parent_id` is set automatically: coordinator → routers → end devices-- **LQI display** — Link Quality Indicator is stored as a node property+- **LQI** — Link Quality Indicator is measured per *link*, so it is stored on the+ edge (and mirrored onto the device as the quality of its link to its parent).+ It is read-only: the import writes it, the edge modal only displays it.- **IoT edges** — Links between devices are added as `IoT / Zigbee` edge type+- **Mesh links (optional)** — By default only the parent tree is imported: one+ edge per device. Tick **Import mesh links** to also draw neighbour-to-neighbour+ links, as a distinct `Zigbee Mesh` edge type in its own colour. Expect far more+ edges — a 37-device network goes from ~36 to ~115 — which is why it is off by+ default and excluded from the scheduled auto-sync.---diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex 1e3db0c..7343616 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -879,12 +879,16 @@ export default function App() {})// Add IoT edges between Zigbee devices: parent bottom -> child topzigbeeEdges.forEach((ze) => {+ // A neighbour link is not a parent attachment: own type, own colour, and+ // drawn sideways so it reads apart from the tree.+ const isMesh = ze.kind === 'mesh'onConnect({source: ze.source,- sourceHandle: 'bottom',+ sourceHandle: isMesh ? 'right' : 'bottom',target: ze.target,- targetHandle: 'top-t',- type: 'iot',+ targetHandle: isMesh ? 'left' : 'top-t',+ type: isMesh ? 'zigbee_mesh' : 'iot',+ lqi: ze.lqi ?? undefined,} as unknown as import('@xyflow/react').Connection)})// Auto-select only the freshly imported nodes so the user can drag thediff --git a/frontend/src/api/client.ts b/frontend/src/api/client.tsindex 2d4e452..b892fa9 100644--- a/frontend/src/api/client.ts+++ b/frontend/src/api/client.ts@@ -433,6 +433,7 @@ export const zigbeeApi = {base_topic?: stringmqtt_tls?: booleanmqtt_tls_insecure?: boolean+ include_mesh_links?: boolean}) =>api.post<{ job_id: string; status: ZigbeeImportJobStatus }>('/zigbee/import', data),@@ -457,6 +458,7 @@ export const zigbeeApi = {base_topic?: stringmqtt_tls?: booleanmqtt_tls_insecure?: boolean+ include_mesh_links?: boolean}) =>api.post<{id: stringdiff --git a/frontend/src/components/canvas/edges/edgeTypes.ts b/frontend/src/components/canvas/edges/edgeTypes.tsindex 160900b..24b874c 100644--- a/frontend/src/components/canvas/edges/edgeTypes.ts+++ b/frontend/src/components/canvas/edges/edgeTypes.ts@@ -4,6 +4,7 @@ export const edgeTypes = {ethernet: HomelableEdge,wifi: HomelableEdge,iot: HomelableEdge,+ zigbee_mesh: HomelableEdge,vlan: HomelableEdge,virtual: HomelableEdge,cluster: HomelableEdge,diff --git a/frontend/src/components/canvas/edges/index.tsx b/frontend/src/components/canvas/edges/index.tsxindex 30a9b27..cdc7bfe 100644--- a/frontend/src/components/canvas/edges/index.tsx+++ b/frontend/src/components/canvas/edges/index.tsx@@ -338,6 +338,9 @@ export function HomelableEdge({ id, source, target, sourceHandleId, targetHandleethernet: { stroke: edgeColors.ethernet, strokeWidth: 2 },wifi: { stroke: edgeColors.wifi, strokeWidth: 1.5, strokeDasharray: '6 3' },iot: { stroke: edgeColors.iot, strokeWidth: 1.5, strokeDasharray: '2 4' },+ // Neighbour link, not a parent attachment: thinner, sparser and slightly+ // faded so a full mesh import stays readable behind the tree.+ zigbee_mesh: { stroke: edgeColors.zigbee_mesh, strokeWidth: 1, strokeDasharray: '1 5', opacity: 0.75 },vlan: { strokeWidth: 2.5 },virtual: { stroke: edgeColors.virtual, strokeWidth: 1, strokeDasharray: '4 4' },cluster: { stroke: edgeColors.cluster, strokeWidth: 2.5, strokeDasharray: '8 3' },diff --git a/frontend/src/components/modals/EdgeModal.tsx b/frontend/src/components/modals/EdgeModal.tsxindex ec7bb49..a2a7806 100644--- a/frontend/src/components/modals/EdgeModal.tsx+++ b/frontend/src/components/modals/EdgeModal.tsx@@ -265,6 +265,22 @@ export function EdgeModal({ open, onClose, onSubmit, onDelete, onClearWaypoints,</label></div>+ {/* Read-only on purpose: LQI is a measurement written by the Zigbee+ import, not a setting. An editable copy would be silently+ overwritten by the next import — `EdgeUpdate` omits it too. */}+ {initial?.lqi != null && (+ <div className="flex flex-col gap-1.5">+ <Label className="text-xs text-muted-foreground">Link Quality (LQI)</Label>+ <div+ className="flex items-center gap-2 px-2.5 h-8 rounded-md border"+ style={{ borderColor: '#30363d', background: '#21262d' }}+ >+ <span className="font-mono text-xs" style={{ color: '#8b949e' }}>{initial.lqi}</span>+ <span className="text-[10px] text-muted-foreground/50 ml-auto">measured</span>+ </div>+ </div>+ )}+{onClearWaypoints && initial?.waypoints && initial.waypoints.length > 0 && (<buttontype="button"diff --git a/frontend/src/components/modals/__tests__/EdgeModal.test.tsx b/frontend/src/components/modals/__tests__/EdgeModal.test.tsxindex 3f313a7..d555d50 100644--- a/frontend/src/components/modals/__tests__/EdgeModal.test.tsx+++ b/frontend/src/components/modals/__tests__/EdgeModal.test.tsx@@ -108,6 +108,30 @@ describe('EdgeModal', () => {expect(onSubmit.mock.calls[0][0].vlan_id).toBeUndefined()})+ // ── LQI (a measurement, never a setting) ──────────────────────────────────++ it('shows a measured LQI', () => {+ render(<EdgeModal open onClose={vi.fn()} onSubmit={vi.fn()} initial={{ type: 'iot', lqi: 150 }} />)+ expect(screen.getByText('Link Quality (LQI)')).toBeTruthy()+ expect(screen.getByText('150')).toBeTruthy()+ })++ it('shows an LQI of 0 — a dead link is a reading, not a missing value', () => {+ render(<EdgeModal open onClose={vi.fn()} onSubmit={vi.fn()} initial={{ type: 'iot', lqi: 0 }} />)+ expect(screen.getByText('Link Quality (LQI)')).toBeTruthy()+ })++ it('hides the LQI row when the edge carries none', () => {+ render(<EdgeModal open onClose={vi.fn()} onSubmit={vi.fn()} initial={{ type: 'ethernet' }} />)+ expect(screen.queryByText('Link Quality (LQI)')).toBeNull()+ })++ it('offers no LQI input — it is written by the import, not edited', () => {+ render(<EdgeModal open onClose={vi.fn()} onSubmit={vi.fn()} initial={{ type: 'iot', lqi: 150 }} />)+ const inputs = document.querySelectorAll('input[type="number"], input[type="text"]')+ expect(Array.from(inputs).some((i) => (i as HTMLInputElement).value === '150')).toBe(false)+ })+// ── Path style ────────────────────────────────────────────────────────────it('defaults to bezier path style', () => {diff --git a/frontend/src/components/zigbee/ZigbeeImportModal.tsx b/frontend/src/components/zigbee/ZigbeeImportModal.tsxindex d951052..e622a69 100644--- a/frontend/src/components/zigbee/ZigbeeImportModal.tsx+++ b/frontend/src/components/zigbee/ZigbeeImportModal.tsx@@ -28,6 +28,7 @@ interface ConnectionForm {base_topic: stringmqtt_tls: booleanmqtt_tls_insecure: boolean+ include_mesh_links: booleanport_user_edited: boolean}@@ -39,6 +40,7 @@ const DEFAULT_FORM: ConnectionForm = {base_topic: 'zigbee2mqtt',mqtt_tls: false,mqtt_tls_insecure: false,+ include_mesh_links: false,port_user_edited: false,}@@ -104,6 +106,7 @@ export function ZigbeeImportModal({ open, onClose, onAddToCanvas, onInventoryImpbase_topic: form.base_topic.trim() || 'zigbee2mqtt',mqtt_tls: form.mqtt_tls,mqtt_tls_insecure: form.mqtt_tls_insecure,+ include_mesh_links: form.include_mesh_links,})const handleTestConnection = async () => {@@ -301,6 +304,18 @@ export function ZigbeeImportModal({ open, onClose, onAddToCanvas, onInventoryImp/>Skip cert verify (self-signed only)</label>+ <label className="flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer">+ <input+ type="checkbox"+ checked={form.include_mesh_links}+ onChange={(e) =>+ setForm((f) => ({ ...f, include_mesh_links: e.target.checked }))+ }+ className="w-3 h-3 accent-[#a855f7] cursor-pointer"+ />+ Import mesh links+ <span className="text-muted-foreground/50">(neighbour links — many more edges)</span>+ </label></div></div>diff --git a/frontend/src/components/zigbee/__tests__/ZigbeeImportModal.test.tsx b/frontend/src/components/zigbee/__tests__/ZigbeeImportModal.test.tsxindex 28e2a83..a6d11b7 100644--- a/frontend/src/components/zigbee/__tests__/ZigbeeImportModal.test.tsx+++ b/frontend/src/components/zigbee/__tests__/ZigbeeImportModal.test.tsx@@ -239,6 +239,31 @@ describe('ZigbeeImportModal', () => {expect(zigbeeApi.importNetwork).not.toHaveBeenCalled()})+ it('does not ask for mesh links unless the box is ticked', async () => {+ vi.mocked(zigbeeApi.importToPending).mockResolvedValue({ data: {} } as never)+ render(<ZigbeeImportModal {...defaultProps} />)+ fireEvent.change(screen.getByPlaceholderText('192.168.1.x or mqtt.local'), {+ target: { value: '192.168.1.100' },+ })+ fireEvent.click(screen.getByRole('button', { name: /import to inventory/i }))++ await waitFor(() => expect(zigbeeApi.importToPending).toHaveBeenCalled())+ expect(vi.mocked(zigbeeApi.importToPending).mock.calls[0][0].include_mesh_links).toBe(false)+ })++ it('sends include_mesh_links when the box is ticked', async () => {+ vi.mocked(zigbeeApi.importToPending).mockResolvedValue({ data: {} } as never)+ render(<ZigbeeImportModal {...defaultProps} />)+ fireEvent.change(screen.getByPlaceholderText('192.168.1.x or mqtt.local'), {+ target: { value: '192.168.1.100' },+ })+ fireEvent.click(screen.getByLabelText(/import mesh links/i))+ fireEvent.click(screen.getByRole('button', { name: /import to inventory/i }))++ await waitFor(() => expect(zigbeeApi.importToPending).toHaveBeenCalled())+ expect(vi.mocked(zigbeeApi.importToPending).mock.calls[0][0].include_mesh_links).toBe(true)+ })+it('switching to canvas mode calls importNetwork and not importToPending', async () => {mockCanvasImport({ nodes: sampleNodes, edges: [], device_count: 2 })diff --git a/frontend/src/components/zigbee/types.ts b/frontend/src/components/zigbee/types.tsindex d6b53bf..0e021ce 100644--- a/frontend/src/components/zigbee/types.ts+++ b/frontend/src/components/zigbee/types.ts@@ -19,6 +19,11 @@ export interface ZigbeeNode {export interface ZigbeeEdge {source: stringtarget: string+ /** Link quality measured for this link, when the map reported one. */+ lqi?: number | null+ /** `tree` = parent attachment (always imported); `mesh` = neighbour link,+ * only present when the import opted into mesh links. */+ kind?: 'tree' | 'mesh'}export interface ZigbeeImportResponse {diff --git a/frontend/src/stores/__tests__/canvasStore/edges.test.ts b/frontend/src/stores/__tests__/canvasStore/edges.test.tsindex 58a9967..025ef7a 100644--- a/frontend/src/stores/__tests__/canvasStore/edges.test.ts+++ b/frontend/src/stores/__tests__/canvasStore/edges.test.ts@@ -104,6 +104,16 @@ describe('canvasStore — edges', () => {expect(useCanvasStore.getState().hasUnsavedChanges).toBe(true)})+ it('updateEdge merges, so a manual edit keeps the measured lqi', () => {+ useCanvasStore.setState((s) => ({+ edges: [...s.edges, { ...makeEdge('e1', 'n1', 'n2'), data: { type: 'iot' as const, lqi: 150 } }],+ }))+ useCanvasStore.getState().updateEdge('e1', { label: 'hallway sensor' })+ const edge = useCanvasStore.getState().edges.find((e) => e.id === 'e1')+ expect(edge?.data?.lqi).toBe(150)+ expect(edge?.data?.label).toBe('hallway sensor')+ })+it('reconnectEdge swaps source/target and normalizes handles', () => {useCanvasStore.setState((s) => ({edges: [...s.edges, { ...makeEdge('e1', 'n1', 'n2'), sourceHandle: 'bottom', targetHandle: 'top' }],diff --git a/frontend/src/stores/canvasStore.ts b/frontend/src/stores/canvasStore.tsindex 7d2c2f2..7918fba 100644--- a/frontend/src/stores/canvasStore.ts+++ b/frontend/src/stores/canvasStore.ts@@ -584,7 +584,7 @@ export const useCanvasStore = create<CanvasState>((rawSet, get) => {sourceHandle: normalizeHandle(extra.sourceHandle),targetHandle: normalizeHandle(extra.targetHandle),type: edgeType,- data: { type: edgeType, label: extra.label, vlan_id: extra.vlan_id, custom_color: extra.custom_color, path_style: extra.path_style, line_style: extra.line_style, width_mult: extra.width_mult, animated: extra.animated, marker_start: extra.marker_start, marker_end: extra.marker_end },+ data: { type: edgeType, label: extra.label, vlan_id: extra.vlan_id, lqi: extra.lqi, custom_color: extra.custom_color, path_style: extra.path_style, line_style: extra.line_style, width_mult: extra.width_mult, animated: extra.animated, marker_start: extra.marker_start, marker_end: extra.marker_end },}return {edges: [...state.edges, newEdge],diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.tsindex cb36ec4..4af2db9 100644--- a/frontend/src/types/index.ts+++ b/frontend/src/types/index.ts@@ -83,7 +83,7 @@ export type TextPosition =| 'bottom-center'| 'bottom-right'-export type EdgeType = 'ethernet' | 'wifi' | 'iot' | 'vlan' | 'virtual' | 'cluster' | 'fibre' | 'electrical'+export type EdgeType = 'ethernet' | 'wifi' | 'iot' | 'zigbee_mesh' | 'vlan' | 'virtual' | 'cluster' | 'fibre' | 'electrical'export type NodeStatus = 'online' | 'offline' | 'pending' | 'unknown'@@ -291,6 +291,8 @@ export interface EdgeData extends Record<string, unknown> {label?: stringvlan_id?: numberspeed?: string+ /** Measured Zigbee link quality. Written by the import, never edited by hand. */+ lqi?: numbercustom_color?: stringpath_style?: EdgePathStyle/** Line render style override. Unset = use the edge type's default preset. */@@ -363,6 +365,7 @@ export const EDGE_TYPE_LABELS: Record<EdgeType, string> = {ethernet: 'Ethernet',wifi: 'Wi-Fi',iot: 'IoT / Zigbee',+ zigbee_mesh: 'Zigbee Mesh',vlan: 'VLAN',virtual: 'Virtual',cluster: 'Cluster',diff --git a/frontend/src/utils/__tests__/canvasSerializer.test.ts b/frontend/src/utils/__tests__/canvasSerializer.test.tsindex b9bd924..88d8885 100644--- a/frontend/src/utils/__tests__/canvasSerializer.test.ts+++ b/frontend/src/utils/__tests__/canvasSerializer.test.ts@@ -260,6 +260,14 @@ describe('serializeEdge', () => {expect(result.animated).toBe(true)})+ it('re-sends a measured LQI so a canvas save cannot wipe it', () => {+ // save_canvas setattrs every field of the payload, so dropping lqi here+ // would overwrite the imported measurement with NULL on the next save.+ // 0 is a real reading (a dead link) and must survive the `?? null`.+ const edge = makeRfEdge({ data: { type: 'iot', lqi: 0 } })+ expect(serializeEdge(edge).lqi).toBe(0)+ })+it('serializes endpoint marker shapes', () => {const edge = makeRfEdge({ data: { type: 'ethernet', marker_start: 'diamond', marker_end: 'arrow' } })const result = serializeEdge(edge)@@ -299,6 +307,7 @@ describe('serializeEdge', () => {expect(result.target_handle).toBeNull()expect(result.label).toBeNull()expect(result.vlan_id).toBeNull()+ expect(result.lqi).toBeNull()expect(result.custom_color).toBeNull()expect(result.path_style).toBeNull()})diff --git a/frontend/src/utils/canvasSerializer.ts b/frontend/src/utils/canvasSerializer.tsindex 4061c35..7e1877a 100644--- a/frontend/src/utils/canvasSerializer.ts+++ b/frontend/src/utils/canvasSerializer.ts@@ -51,6 +51,7 @@ export interface ApiEdge {label?: string | nullvlan_id?: number | nullspeed?: string | null+ lqi?: number | nullcustom_color?: string | nullpath_style?: string | nullline_style?: string | null@@ -180,6 +181,9 @@ export function serializeEdge(e: Edge<EdgeData>): Record<string, unknown> {label: e.data?.label ?? null,vlan_id: e.data?.vlan_id ?? null,speed: e.data?.speed ?? null,+ // Must be re-sent: `save_canvas` setattrs every field of the payload, so+ // omitting it here would overwrite a measured LQI with NULL on every save.+ lqi: e.data?.lqi ?? null,custom_color: e.data?.custom_color ?? null,path_style: e.data?.path_style ?? null,line_style: e.data?.line_style ?? null,diff --git a/frontend/src/utils/edgeColors.ts b/frontend/src/utils/edgeColors.tsindex de913a7..4842409 100644--- a/frontend/src/utils/edgeColors.ts+++ b/frontend/src/utils/edgeColors.ts@@ -4,6 +4,7 @@ export const EDGE_DEFAULT_COLORS: Record<EdgeType, string> = {ethernet: '#30363d',wifi: '#00d4ff',iot: '#e3b341',+ zigbee_mesh: '#a855f7',vlan: '#00d4ff',virtual: '#8b949e',cluster: '#ff6e00',diff --git a/frontend/src/utils/edgeLineStyle.ts b/frontend/src/utils/edgeLineStyle.tsindex c5b674c..e61627a 100644--- a/frontend/src/utils/edgeLineStyle.ts+++ b/frontend/src/utils/edgeLineStyle.ts@@ -17,6 +17,7 @@ export const EDGE_TYPE_BASE_WIDTH: Record<EdgeType, number> = {ethernet: 2,wifi: 1.5,iot: 1.5,+ zigbee_mesh: 1,vlan: 2.5,virtual: 1,cluster: 2.5,@@ -29,6 +30,7 @@ export const EDGE_TYPE_DEFAULT_LINE: Record<EdgeType, EdgeLineStyle> = {ethernet: 'solid',wifi: 'dashed',iot: 'dotted',+ zigbee_mesh: 'dotted',vlan: 'solid',virtual: 'dashed',cluster: 'dashed',diff --git a/frontend/src/utils/themes.ts b/frontend/src/utils/themes.tsindex 5a15bb2..adc2801 100644--- a/frontend/src/utils/themes.ts+++ b/frontend/src/utils/themes.ts@@ -101,6 +101,7 @@ export const THEMES: Record<ThemeId, ThemePreset> = {ethernet: '#30363d',wifi: '#00d4ff',iot: '#e3b341',+ zigbee_mesh: '#a855f7',vlan: '#00d4ff',virtual: '#8b949e',cluster: '#ff6e00',@@ -184,6 +185,7 @@ export const THEMES: Record<ThemeId, ThemePreset> = {ethernet: '#1c1c1e',wifi: '#22d3ee',iot: '#fbbf24',+ zigbee_mesh: '#c084fc',vlan: '#22d3ee',virtual: '#6b7280',cluster: '#fb923c',@@ -267,6 +269,7 @@ export const THEMES: Record<ThemeId, ThemePreset> = {ethernet: '#d0d7de',wifi: '#0284c7',iot: '#d97706',+ zigbee_mesh: '#7c3aed',vlan: '#0284c7',virtual: '#9ca3af',cluster: '#ea580c',@@ -350,6 +353,7 @@ export const THEMES: Record<ThemeId, ThemePreset> = {ethernet: '#1a1a3a',wifi: '#00ffff',iot: '#ffff00',+ zigbee_mesh: '#ff00ff',vlan: '#00ffff',virtual: '#8888cc',cluster: '#ff8800',@@ -433,6 +437,7 @@ export const THEMES: Record<ThemeId, ThemePreset> = {ethernet: '#003300',wifi: '#00ff41',iot: '#66ff33',+ zigbee_mesh: '#00cc66',vlan: '#00cc33',virtual: '#004400',cluster: '#33ff66',@@ -520,6 +525,7 @@ export const THEMES: Record<ThemeId, ThemePreset> = {virtual: '#8b949e',cluster: '#ff6e00',fibre: '#22d3ee',+ zigbee_mesh: '#a855f7',electrical: '#e3b341',},edgeSelectedColor: '#00d4ff',diff --git a/mcp/app/tools.py b/mcp/app/tools.pyindex 7f21235..b34706e 100644--- a/mcp/app/tools.py+++ b/mcp/app/tools.py@@ -23,7 +23,7 @@ NODE_TYPES = [# Kept in sync manually with frontend/src/types/index.ts EdgeType.# Sync is enforced automatically by test_edge_types_in_sync_with_frontend (mcp/tests/test_edge_types_sync.py).EDGE_TYPES = [- "ethernet", "wifi", "iot", "vlan", "virtual", "cluster", "fibre", "electrical",+ "ethernet", "wifi", "iot", "zigbee_mesh", "vlan", "virtual", "cluster", "fibre", "electrical",]# Shared field schemas mirroring backend NodeBase / NodeUpdate (backend/app/schemas/nodes.py).