From 4957a08198ecd80a7f3fb1aa7bf84b0d1b15310a Mon Sep 17 00:00:00 2001 From: serversdwn Date: Thu, 29 Jan 2026 16:37:59 +0000 Subject: [PATCH] fix: improvedr pair status sharing. --- backend/services/snapshot.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/services/snapshot.py b/backend/services/snapshot.py index 856cdc5..ec0dc2c 100644 --- a/backend/services/snapshot.py +++ b/backend/services/snapshot.py @@ -151,11 +151,23 @@ def emit_status_snapshot(): # --- Derive modem status from paired devices --- # Modems don't have their own check-in system, so we inherit status # from whatever device they're paired with (seismograph or SLM) + # Check both directions: modem.deployed_with_unit_id OR device.deployed_with_modem_id for unit_id, unit_data in units.items(): if unit_data.get("device_type") == "modem" and not unit_data.get("retired"): + paired_unit_id = None roster_unit = roster.get(unit_id) + + # First, check if modem has deployed_with_unit_id set if roster_unit and roster_unit.deployed_with_unit_id: paired_unit_id = roster_unit.deployed_with_unit_id + else: + # Fallback: check if any device has this modem in deployed_with_modem_id + for other_id, other_roster in roster.items(): + if other_roster.deployed_with_modem_id == unit_id: + paired_unit_id = other_id + break + + if paired_unit_id: paired_unit = units.get(paired_unit_id) if paired_unit: # Inherit status from paired device