From 44c8e87959cf95797c7ee4588f9e4a6bf041c39c Mon Sep 17 00:00:00 2001 From: Cobra Date: Wed, 15 Apr 2026 13:19:05 -0400 Subject: [PATCH] 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. --- net_alerter/net_alerter.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net_alerter/net_alerter.py b/net_alerter/net_alerter.py index 04a5235..63f7e1d 100644 --- a/net_alerter/net_alerter.py +++ b/net_alerter/net_alerter.py @@ -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}")