Notify about devices that have NEVER been seen before (deduped against DB).
(self, new_ips)
| 157 | return (time.time() - self._startup_ts) < self._startup_grace_s |
| 158 | |
| 159 | def notify_new_devices(self, new_ips): |
| 160 | """Notify about devices that have NEVER been seen before (deduped against DB).""" |
| 161 | if not self.is_enabled(): |
| 162 | return |
| 163 | if not self.shared_data.config.get("pushover_notify_new_device", True): |
| 164 | return |
| 165 | truly_new = [ip for ip in new_ips if ip not in self._notified_devices] |
| 166 | if not truly_new: |
| 167 | return |
| 168 | self._notified_devices.update(truly_new) |
| 169 | # Suppress notification during startup grace period — just record the IPs |
| 170 | if self._in_startup_grace(): |
| 171 | logger.debug(f"Pushover: suppressed new-device alert for {len(truly_new)} IP(s) during startup grace") |
| 172 | return |
| 173 | count = len(truly_new) |
| 174 | ip_list = ", ".join(sorted(truly_new)[:5]) |
| 175 | suffix = f" (+{count - 5} more)" if count > 5 else "" |
| 176 | msg = f"⚔️ {count} new device(s) discovered on the network for the first time:\n{ip_list}{suffix}" |
| 177 | threading.Thread(target=self.send, args=(msg, "Ragnar — New Device"), daemon=True).start() |
| 178 | |
| 179 | def notify_device_lost(self, lost_ips): |
| 180 | """Notify when devices go offline (and remember them for back-online detection).""" |
no test coverage detected