From 4e81664442106c52771424f4b0b844264a6b457b Mon Sep 17 00:00:00 2001 From: jwansek Date: Fri, 6 Jun 2025 09:04:19 +0100 Subject: Converted some types to float because InfluxDB is really pedantic about types --- mqtt-client/mqtt-client.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'mqtt-client/mqtt-client.py') diff --git a/mqtt-client/mqtt-client.py b/mqtt-client/mqtt-client.py index f81d1d6..602774b 100644 --- a/mqtt-client/mqtt-client.py +++ b/mqtt-client/mqtt-client.py @@ -98,8 +98,6 @@ class MQTTClient: friendlyname = fields.pop("Name") del fields["Device"] print("Zigbee device '%s' reported: %s" % (friendlyname, str(fields))) - if "Read" not in fields.keys(): - self.append_influxdb(fields, "zigbee", {"friendlyname": friendlyname, "id": zigbee_id}) if zigbee_id == "0x7327" and friendlyname == "TVButton" and "Power" in fields.keys(): if fields["Power"] == 2: @@ -113,9 +111,11 @@ class MQTTClient: self.toggle_plug("TasmotaHarveyPC") if "Humidity" in fields.keys(): + fields["Humidity"] = float(fields["Humidity"]) self.humidity_prom.labels(location = friendlyname).set(fields["Humidity"]) elif "Temperature" in fields.keys(): - self.temperature_prom.labels(location = friendlyname).set(fields["Temperature"]) + 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: self.doorsensor_prom.labels(location = friendlyname).state("opened") @@ -123,6 +123,9 @@ class MQTTClient: elif fields["ZoneStatus"] == 0 and fields["Contact"] == 0: self.doorsensor_prom.labels(location = friendlyname).state("closed") + if "Read" not in fields.keys(): + self.append_influxdb(fields, "zigbee", {"friendlyname": friendlyname, "id": zigbee_id}) + def set_plug(self, friendlyname, payload): t = "cmnd/TasmotaPlug/%s/Power" % friendlyname self.mqttc.publish(t, payload = payload) -- cgit v1.2.3