diff options
| author | jwansek <eddie.atten.ea29@gmail.com> | 2026-08-25 17:34:11 +0100 |
|---|---|---|
| committer | jwansek <eddie.atten.ea29@gmail.com> | 2026-08-25 17:34:11 +0100 |
| commit | d62eee11159a4033b1dd5bceb030a2fab63ebaa0 (patch) | |
| tree | 61c70694d264ff3cf9173a04314918d744bda8e6 /powerButtons.py | |
| parent | d475d1abc250644f47b7c7dadb7b6932ead71ec9 (diff) | |
| download | HomelabPowerButtons-d62eee11159a4033b1dd5bceb030a2fab63ebaa0.tar.gz HomelabPowerButtons-d62eee11159a4033b1dd5bceb030a2fab63ebaa0.zip | |
Fixed bug that stopped refreshing if a single tasmota failed to ping
Diffstat (limited to 'powerButtons.py')
| -rw-r--r-- | powerButtons.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/powerButtons.py b/powerButtons.py index abb4b21..98b419f 100644 --- a/powerButtons.py +++ b/powerButtons.py @@ -129,6 +129,9 @@ class App(tk.Tk): self.mqtt_thread.start() def _after(self): + self.bottom_widget.update_in_sec = 30 + self.after(30 * 1000, self._after) + for ip in self.config["tasmota"]["plugs"].split(","): try: data = query_tasmota_power(ip, self.config["tasmota"]["password"]) @@ -140,7 +143,11 @@ class App(tk.Tk): } else: fields = tasmota_query_to_fields(data) - friendlyname = list(self.tasmota_ips.keys())[list(self.tasmota_ips.values()).index(ip)] + try: + friendlyname = list(self.tasmota_ips.keys())[list(self.tasmota_ips.values()).index(ip)] + except ValueError: + print("Couldn't find %s :c" % ip) + continue self.devices[friendlyname] = fields self.device_widgets[friendlyname].update() @@ -166,10 +173,7 @@ class App(tk.Tk): self.devices[profile]["on"] = False # print(profile, self.devices[profile]) - self.device_widgets[profile].update() - - self.bottom_widget.update_in_sec = 30 - self.after(30 * 1000, self._after) + self.device_widgets[profile].update() def _on_connect_cb(self, mqtt, userdata, flags, rc): print("Connected to broker") @@ -372,7 +376,6 @@ def switch_mqtt_to_fields(mqtt_fields): else: return v - return {OMADA_MQTT_TRANSFORMATIONS[k]: transform_power(k, v) for k, v in mqtt_fields.items() if k in OMADA_MQTT_TRANSFORMATIONS.keys()} def send_raw_tasmota_http(host, password, command): |
