diff options
| author | jwansek <eddie.atten.ea29@gmail.com> | 2026-05-28 20:52:14 +0100 |
|---|---|---|
| committer | jwansek <eddie.atten.ea29@gmail.com> | 2026-05-28 20:52:14 +0100 |
| commit | 696b1ee7559ad6f6fec2f94118604508d6251cdc (patch) | |
| tree | 1e10ae58cf7e8d20415d65d6ca626d8492340bce | |
| parent | 6f5aa03cf4ea61fcdec0f7d3897e9919e4223e57 (diff) | |
| download | power.eda.gay-696b1ee7559ad6f6fec2f94118604508d6251cdc.tar.gz power.eda.gay-696b1ee7559ad6f6fec2f94118604508d6251cdc.zip | |
Changed the way we log door sensor readings
| -rw-r--r-- | mqtt-client/mqtt-client.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/mqtt-client/mqtt-client.py b/mqtt-client/mqtt-client.py index 2091161..19ad845 100644 --- a/mqtt-client/mqtt-client.py +++ b/mqtt-client/mqtt-client.py @@ -118,6 +118,11 @@ class MQTTClient: del fields["Device"] print("Zigbee device '%s' reported: %s" % (friendlyname, str(fields))) + if friendlyname == "DoorSensor": + with open(os.path.join(os.path.dirname(__file__), "door_log.csv"), "a") as f: + f.write("%s,%s,%s" % (datetime.datetime.now().astimezone().isoformat(), friendlyname, ",".join(sorted(["%s=%s" % (k, v) for k, v in fields.items()])))) + + if zigbee_id == "0x0A05" and friendlyname == "TVButton2" and "Power" in fields.keys(): if fields["Power"] == 2: print("TV Zigbee button pressed, toggling TasmotaTV Tasmota Plug") @@ -138,9 +143,6 @@ 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(): - with open(os.path.join(os.path.dirname(__file__), "door_log.csv"), "a") as f: - f.write("%s,Contact=%d,%d\n" % (datetime.datetime.now().astimezone().isoformat(), fields["Contact"], fields["Contact"])) - if fields["ZoneStatus"] == 1 and fields["Contact"] == 1: self.doorsensor_prom.labels(location = friendlyname).state("opened") self.door_opened_counter.labels(location = friendlyname).inc() |
