Notify when devices go offline (and remember them for back-online detection).
(self, lost_ips)
| 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).""" |
| 181 | if not self.is_enabled(): |
| 182 | return |
| 183 | # Always track offline state even if notifications are disabled, so back-online works |
| 184 | self._offline_devices.update(lost_ips) |
| 185 | if self._in_startup_grace(): |
| 186 | logger.debug(f"Pushover: suppressed device-lost alert for {len(lost_ips)} IP(s) during startup grace") |
| 187 | return |
| 188 | if not self.shared_data.config.get("pushover_notify_device_lost", False): |
| 189 | return |
| 190 | if not lost_ips: |
| 191 | return |
| 192 | count = len(lost_ips) |
| 193 | ip_list = ", ".join(sorted(lost_ips)[:5]) |
| 194 | suffix = f" (+{count - 5} more)" if count > 5 else "" |
| 195 | msg = f"🛡️ {count} device(s) went offline:\n{ip_list}{suffix}" |
| 196 | threading.Thread(target=self.send, args=(msg, "Ragnar — Device Lost"), daemon=True).start() |
| 197 | |
| 198 | def notify_device_back_online(self, appeared_ips): |
| 199 | """Notify when a previously known device that went offline comes back online.""" |
no test coverage detected