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

Method notify_new_devices

pushover_service.py:159–177  ·  view source on GitHub ↗

Notify about devices that have NEVER been seen before (deduped against DB).

(self, new_ips)

Source from the content-addressed store, hash-verified

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

Callers 1

sync_all_countsFunction · 0.95

Calls 6

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

Tested by

no test coverage detected