fix: improvedr pair status sharing.
This commit is contained in:
@@ -151,11 +151,23 @@ def emit_status_snapshot():
|
|||||||
# --- Derive modem status from paired devices ---
|
# --- Derive modem status from paired devices ---
|
||||||
# Modems don't have their own check-in system, so we inherit status
|
# Modems don't have their own check-in system, so we inherit status
|
||||||
# from whatever device they're paired with (seismograph or SLM)
|
# 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():
|
for unit_id, unit_data in units.items():
|
||||||
if unit_data.get("device_type") == "modem" and not unit_data.get("retired"):
|
if unit_data.get("device_type") == "modem" and not unit_data.get("retired"):
|
||||||
|
paired_unit_id = None
|
||||||
roster_unit = roster.get(unit_id)
|
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:
|
if roster_unit and roster_unit.deployed_with_unit_id:
|
||||||
paired_unit_id = 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)
|
paired_unit = units.get(paired_unit_id)
|
||||||
if paired_unit:
|
if paired_unit:
|
||||||
# Inherit status from paired device
|
# Inherit status from paired device
|
||||||
|
|||||||
Reference in New Issue
Block a user