Any enrolled non-infrastructure device marks location as occupied
This commit is contained in:
@@ -889,14 +889,14 @@ def _update_occupancy_state_unlocked() -> None:
|
||||
"""
|
||||
global location_occupancy
|
||||
|
||||
# Count active personal devices (in known_devices, not marked departing)
|
||||
active_personal_count = 0
|
||||
# Count active enrolled devices that are not infrastructure (in known_devices, not marked departing, not infrastructure IP)
|
||||
active_enrolled_count = 0
|
||||
for mac, dev in known_devices.items():
|
||||
if not dev.get('departing', False) and is_personal_device(mac):
|
||||
active_personal_count += 1
|
||||
if not dev.get('departing', False) and dev['ip'] not in infrastructure_ips:
|
||||
active_enrolled_count += 1
|
||||
|
||||
# Determine new occupancy state
|
||||
new_occupancy = "OCCUPIED" if active_personal_count > 0 else "VACANT"
|
||||
new_occupancy = "OCCUPIED" if active_enrolled_count > 0 else "VACANT"
|
||||
|
||||
# Fire alert on transitions (but not UNKNOWN → OCCUPIED on startup)
|
||||
if new_occupancy != location_occupancy:
|
||||
@@ -908,7 +908,7 @@ def _update_occupancy_state_unlocked() -> None:
|
||||
logging.debug(f"Suppressing startup occupancy alert: UNKNOWN → OCCUPIED")
|
||||
|
||||
location_occupancy = new_occupancy
|
||||
logging.info(f"Location occupancy updated to {location_occupancy} ({active_personal_count} personal devices active)")
|
||||
logging.info(f"Location occupancy updated to {location_occupancy} ({active_enrolled_count} enrolled non-infra devices active)")
|
||||
|
||||
|
||||
def update_occupancy_state() -> None:
|
||||
|
||||
Reference in New Issue
Block a user