diff options
| author | jwansek <eddie.atten.ea29@gmail.com> | 2026-06-19 18:00:55 +0100 |
|---|---|---|
| committer | jwansek <eddie.atten.ea29@gmail.com> | 2026-06-19 18:00:55 +0100 |
| commit | 79bc0eb0f08638c8ded80b04e4d0ae6f18cbe417 (patch) | |
| tree | 6ca948f136d016ce48cccbbe1c794c7c9861781a /mqtt-client | |
| parent | ae73799694b23cc0af558e2ed8bc9b77fd818c47 (diff) | |
| download | power.eda.gay-79bc0eb0f08638c8ded80b04e4d0ae6f18cbe417.tar.gz power.eda.gay-79bc0eb0f08638c8ded80b04e4d0ae6f18cbe417.zip | |
Started pushing SNMP POE shit to MQTT also
Diffstat (limited to 'mqtt-client')
| -rw-r--r-- | mqtt-client/mqtt-client.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/mqtt-client/mqtt-client.py b/mqtt-client/mqtt-client.py index f45fbf1..c1a05e4 100644 --- a/mqtt-client/mqtt-client.py +++ b/mqtt-client/mqtt-client.py @@ -55,9 +55,9 @@ class MQTTClient: self.zigbee_plugs = {"MikroTikZigbeePlug"} self.zigbee_to_tasmota_transformations = { - "RMSVoltage": "Voltage", - "ActivePower": "Power", - "RMSCurrent": "Current" + "RMSVoltage": ("Voltage", int), + "ActivePower": ("Power", int), + "RMSCurrent": ("Current", float) } # print(self.send_raw_tasmota_http("192.168.5.6", os.environ["MQTT_PASSWD"], "Power")) @@ -96,9 +96,13 @@ class MQTTClient: fields2 = {} for k, v in fields.items(): if k in self.zigbee_to_tasmota_transformations.keys(): - fields2[self.zigbee_to_tasmota_transformations[k]] = v + fields2[self.zigbee_to_tasmota_transformations[k][0]] = self.zigbee_to_tasmota_transformations[k][1](v) + print("Logged the following information for the zigbee plug '%s' as a tasmota plug: %s" % (friendlyname, str(fields2))) self.append_influxdb(fields2, "tasmota_power", {"plug": friendlyname}) + + for k, v in fields2.items(): + self.tasmota_power_prom.labels(plug = friendlyname, field = k).set(v) def handle_plug(self, msg_j, location): print("'%s' is using %.1fw @ %s. %.1fkWh so far today, %.1fkWh yesterday" % (location, msg_j["ENERGY"]["Power"], msg_j["Time"], msg_j["ENERGY"]["Today"], msg_j["ENERGY"]["Yesterday"])) @@ -160,10 +164,10 @@ class MQTTClient: fields["Temperature"] = float(fields["Temperature"]) self.temperature_prom.labels(location = friendlyname).set(fields["Temperature"]) elif "ZoneStatus" in fields.keys() and "Contact" in fields.keys(): - if fields["ZoneStatus"] == 1 and fields["Contact"] == 1: + if fields["ZoneStatusChange"] == 1 and fields["ZoneStatusChangeZone"] == 1: self.doorsensor_prom.labels(location = friendlyname).state("opened") self.door_opened_counter.labels(location = friendlyname).inc() - elif fields["ZoneStatus"] == 0 and fields["Contact"] == 0: + elif fields["ZoneStatusChange"] == 0 and fields["ZoneStatusChangeZone"] == 1: self.doorsensor_prom.labels(location = friendlyname).state("closed") if "Read" not in fields.keys(): |
