diff --git a/uptime_kuma_api/api.py b/uptime_kuma_api/api.py index 866d71d..85a4593 100644 --- a/uptime_kuma_api/api.py +++ b/uptime_kuma_api/api.py @@ -378,6 +378,7 @@ class UptimeKumaApi(object): "uptime": None, "heartbeat": None, "info": None, + "certInfo": None } self.sio.on("connect", self._event_connect) @@ -392,11 +393,16 @@ class UptimeKumaApi(object): self.sio.on("uptime", self._event_uptime) self.sio.on("heartbeat", self._event_heartbeat) self.sio.on("info", self._event_info) + self.sio.on("certInfo", self._event_cert_info) self.connect(url) def _get_event_data(self, event): + monitor_events = ["avgPing", "uptime", "heartbeatList", "importantHeartbeatList", "certInfo", "heartbeat"] while self._event_data[event] is None: + # do not wait for events that are not sent + if self._event_data["monitorList"] == {} and event in monitor_events: + return [] time.sleep(0.01) time.sleep(0.01) # wait for multiple messages return self._event_data[event] @@ -472,6 +478,14 @@ class UptimeKumaApi(object): def _event_info(self, data): self._event_data["info"] = data + def _event_cert_info(self, id_, data): + if self._event_data["certInfo"] is None: + self._event_data["certInfo"] = [] + self._event_data["certInfo"].append({ + "id": id_, + "data": data, + }) + # connection def connect(self, url: str): @@ -685,6 +699,11 @@ class UptimeKumaApi(object): def avg_ping(self): return self._get_event_data("avgPing") + # cert info + + def cert_info(self): + return self._get_event_data("certInfo") + # uptime def uptime(self): diff --git a/uptime_kuma_api/events.py b/uptime_kuma_api/events.py new file mode 100644 index 0000000..e69de29