MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / notify_device_lost

Method notify_device_lost

pushover_service.py:179–196  ·  view source on GitHub ↗

Notify when devices go offline (and remember them for back-online detection).

(self, lost_ips)

Source from the content-addressed store, hash-verified

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."""

Callers 1

sync_all_countsFunction · 0.95

Calls 6

is_enabledMethod · 0.95
_in_startup_graceMethod · 0.95
debugMethod · 0.80
updateMethod · 0.45
getMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected