diff --git a/net_alerter/net_alerter.py b/net_alerter/net_alerter.py index cf9f458..b39710a 100644 --- a/net_alerter/net_alerter.py +++ b/net_alerter/net_alerter.py @@ -898,14 +898,11 @@ def _update_occupancy_state_unlocked() -> None: # Determine new occupancy state new_occupancy = "OCCUPIED" if active_enrolled_count > 0 else "VACANT" - # Fire alert on transitions (but not UNKNOWN → OCCUPIED on startup) + # Fire alert on all transitions including startup UNKNOWN → OCCUPIED if new_occupancy != location_occupancy: - if not (location_occupancy == "UNKNOWN" and new_occupancy == "OCCUPIED"): - msg = f"[NET] Location: {new_occupancy}" - logging.info(msg) - send_alert(msg) - else: - logging.debug(f"Suppressing startup occupancy alert: UNKNOWN → OCCUPIED") + msg = f"[NET] Location: {new_occupancy}" + logging.info(msg) + send_alert(msg) location_occupancy = new_occupancy logging.info(f"Location occupancy updated to {location_occupancy} ({active_enrolled_count} enrolled non-infra devices active)") @@ -914,7 +911,7 @@ def _update_occupancy_state_unlocked() -> None: def update_occupancy_state() -> None: """ Update location occupancy state based on presence of personal devices. - Fires Matrix alerts on VACANT/OCCUPIED transitions (not on UNKNOWN transitions). + Fires Matrix alerts on all VACANT/OCCUPIED transitions including startup. Thread-safe: acquires locks in order: known_lock, then occupancy_lock. """ with known_lock: