diff options
| author | jwansek <eddie.atten.ea29@gmail.com> | 2026-05-28 20:33:30 +0100 |
|---|---|---|
| committer | jwansek <eddie.atten.ea29@gmail.com> | 2026-05-28 20:33:30 +0100 |
| commit | 6f5aa03cf4ea61fcdec0f7d3897e9919e4223e57 (patch) | |
| tree | 198eab75a86be736fa729964b1573a8cba2629e5 /mqtt-client | |
| parent | 04d5ffaef118268766f32ff587036d2e5f55c096 (diff) | |
| download | power.eda.gay-6f5aa03cf4ea61fcdec0f7d3897e9919e4223e57.tar.gz power.eda.gay-6f5aa03cf4ea61fcdec0f7d3897e9919e4223e57.zip | |
Added door sensor csv output
Diffstat (limited to 'mqtt-client')
| -rw-r--r-- | mqtt-client/mqtt-client.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/mqtt-client/mqtt-client.py b/mqtt-client/mqtt-client.py index ad6227c..2091161 100644 --- a/mqtt-client/mqtt-client.py +++ b/mqtt-client/mqtt-client.py @@ -3,6 +3,7 @@ from influxdb_client import InfluxDBClient, Point, WritePrecision from influxdb_client.client.write_api import SYNCHRONOUS import prometheus_client import threading +import datetime import requests import asyncio import time @@ -137,6 +138,9 @@ 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() |
