Alert on genuinely new (never-seen-before) devices #17
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Detection: track first-ever-seen per MAC in a dedicated table (decoupled from the IP-keyed devices table, since DHCP IP churn would otherwise cause false new-device alerts for devices whose IP just changed). Bootstrap-safe: first run seeds the baseline without alerting on the whole existing device list.
Delivery: push a Home Assistant persistent_notification (user already runs HA at CT118) when a new MAC appears. Needs a long-lived access token from the user.
Also surface in the dashboard UI: a 'New' badge for devices first seen recently, independent of notification delivery.
Done and deployed. seen_macs table (permanent, MAC-keyed, insert-only) tracks first-ever-seen per device, bootstrap-safe so turning this on didn't alert on the entire existing 71-device population.
Found and fixed a real bug via actual deployment verification, not just the unit test: the notification path was correctly bootstrap-safe, but the separate dashboard "new" badge wasn't bootstrap-aware at all -- 65/71 devices showed as new on first deploy. Added is_bootstrap tracking + a migration that backfills it correctly for the already-deployed instance. Verified fixed (0 false positives), then did a full synthetic end-to-end test (injected a fake device into the discovery pipeline, confirmed it alone got flagged, cleaned up afterward).
Still pending: HOME_ASSISTANT_TOKEN from the user to enable the actual push notification (detection + dashboard badge work regardless; only the HA push is gated on that).