Gate arrival/departure alerts to phones and wearables only
Non-phone OUIs (IoT, thermostats, TVs, etc.) are silently enrolled for presence tracking but never trigger Matrix alerts. Only devices matching MOBILE_DEVICE_OUIS or with an explicit label in device_labels produce alerts.
This commit is contained in:
@@ -1110,6 +1110,15 @@ def on_arrival(mac: str, ip: str, hostname: str = "") -> None:
|
||||
'last_seen': now
|
||||
}
|
||||
|
||||
# Only alert for phones/wearables (MOBILE_DEVICE_OUIS) or explicitly labeled devices.
|
||||
# Everything else is enrolled silently.
|
||||
oui = mac.replace(":", "").upper()[:6]
|
||||
normalized = _normalize_mac(mac)
|
||||
if oui not in MOBILE_DEVICE_OUIS and normalized not in device_labels:
|
||||
logging.debug(f"Silent enroll {mac} — not a phone/wearable OUI and no label")
|
||||
update_occupancy_state()
|
||||
return
|
||||
|
||||
# Delay alert 2 seconds so mDNS can update the hostname before we send.
|
||||
# The timer callback reads from known_devices at fire time to get the real name.
|
||||
def _send_arrival_alert():
|
||||
@@ -1146,6 +1155,13 @@ def on_departure(mac: str) -> None:
|
||||
logging.debug(f"Ignoring departure for infrastructure IP {dev['ip']} (MAC:{mac})")
|
||||
return
|
||||
|
||||
# Only alert departure for phones/wearables or labeled devices
|
||||
oui = mac.replace(":", "").upper()[:6]
|
||||
if oui not in MOBILE_DEVICE_OUIS and _normalize_mac(mac) not in device_labels:
|
||||
known_devices.pop(mac, None)
|
||||
logging.debug(f"Silent depart {mac} — not a phone/wearable OUI and no label")
|
||||
return
|
||||
|
||||
# Check if this is part of an interface flap (suppress simultaneous mass-departure)
|
||||
if _check_flap(mac):
|
||||
logging.debug(f"Flap suppression: ignoring departure for {mac}")
|
||||
|
||||
Reference in New Issue
Block a user