diff options
| -rw-r--r-- | powerButtons.ini.example | 10 | ||||
| -rw-r--r-- | powerButtons.py | 15 |
2 files changed, 15 insertions, 10 deletions
diff --git a/powerButtons.ini.example b/powerButtons.ini.example index 1e50e9c..af13d9e 100644 --- a/powerButtons.ini.example +++ b/powerButtons.ini.example @@ -1,15 +1,15 @@ [zigbee] mqtt_host=192.168.69.5 mqtt_username=eden -mqtt_password=************** +mqtt_password=******************* tasmota_topic=tele/TasmotaZigbee/TasmotaZigbee/SENSOR snmp_topic=tele/SwitchSNMP/+/+/SENSOR cmd_mqtt_topic=cmnd/TasmotaZigbee/TasmotaZigbee/ZbSend friendlynames=MikroTikZigbeePlug,OnAirLight [tasmota] -password=******************** -plugs=192.168.5.5,192.168.5.6,192.168.5.7,192.168.5.8,192.168.5.10,192.168.5.11,192.168.5.12,192.168.5.13,192.168.5.14,192.168.5.15 +password==******************* +plugs=192.168.5.5,192.168.5.6,192.168.5.7,192.168.5.8,192.168.5.10,192.168.5.11,192.168.5.12,192.168.5.13,192.168.5.14,192.168.5.15,192.168.5.16 disabled=NASPlug,SwitchPlug,ServerPlug [omada] @@ -17,9 +17,11 @@ baseurl = https://192.168.69.2:30077 site = Home verify = False username = admin -password = ************************ +password = =******************* [omada_profile_ports] +IntelComputeStick = 192.168.69.28:16 +Jetson = 192.168.69.28:9 PiKVM = 192.168.69.28:8 Firestick = 192.168.69.27:3 Cluster = 192.168.69.28:17,192.168.69.28:18,192.168.69.28:19,192.168.69.28:20,192.168.69.28:21,192.168.69.28:22 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): |
