feat(zigbee): populate IEEE/Vendor/Model/LQI properties on approve and re-import

- Approval (single + bulk) of zigbee pending devices now writes IEEE, Vendor,
  Model, LQI into Node.properties so they show in the right panel.
- Zigbee re-import refreshes properties on existing canvas Nodes and skips
  creating a pending row when the device was already approved — keeps
  approved devices out of pending/hidden modals.
- Coordinator Node also receives the same properties on first creation and
  on re-import.
- Remove the Parent Container selector from the add/edit node modal.
This commit is contained in:
Pouzor
2026-05-14 00:17:13 +02:00
parent 8541922386
commit 3a303a1376
8 changed files with 234 additions and 80 deletions
+18 -1
View File
@@ -23,7 +23,7 @@ from app.schemas.zigbee import (
ZigbeeTestConnectionRequest,
ZigbeeTestConnectionResponse,
)
from app.services.zigbee_service import fetch_networkmap, test_mqtt_connection
from app.services.zigbee_service import build_zigbee_properties, fetch_networkmap, test_mqtt_connection
logger = logging.getLogger(__name__)
router = APIRouter()
@@ -142,10 +142,15 @@ async def _persist_pending_import(
ieee = n.get("ieee_address")
if not ieee:
continue
props = build_zigbee_properties(
ieee, n.get("vendor"), n.get("model"), n.get("lqi")
)
if n.get("device_type") == "Coordinator":
existing = await db.execute(select(Node).where(Node.ieee_address == ieee))
existing_node = existing.scalar_one_or_none()
if existing_node:
existing_node.properties = props
coordinator_out = ZigbeeCoordinatorOut(
id=existing_node.id,
label=existing_node.label,
@@ -161,6 +166,7 @@ async def _persist_pending_import(
check_method="none",
ieee_address=ieee,
services=[],
properties=props,
)
db.add(node)
await db.flush()
@@ -169,6 +175,17 @@ async def _persist_pending_import(
)
continue
# If the device has already been approved as a canvas Node, refresh
# its properties and skip creating a pending row (keeps approved
# devices out of pending/hidden modals on re-import).
existing_node_q = await db.execute(
select(Node).where(Node.ieee_address == ieee)
)
existing_node = existing_node_q.scalar_one_or_none()
if existing_node:
existing_node.properties = props
continue
result = await db.execute(
select(PendingDevice).where(PendingDevice.ieee_address == ieee)
)