diff --git a/routermon/routermon.py b/routermon/routermon.py index e821b8f..ae18ac9 100644 --- a/routermon/routermon.py +++ b/routermon/routermon.py @@ -74,6 +74,7 @@ def main() -> int: ###### END MAIN LOOP ######### ############################## connection.disconnect() + write_client.close() return 0 if __name__ == "__main__": diff --git a/upsmon/ups.py b/upsmon/ups.py index 41b914d..ba3e2be 100644 --- a/upsmon/ups.py +++ b/upsmon/ups.py @@ -4,11 +4,10 @@ import time import serial import logging - -from pyutils.utils import * from copy import deepcopy +from pyutils.utils import * from dataclasses import dataclass -from influxdb_client_3 import InfluxDBClient3 +from influxdb_client_3 import InfluxDBClient3, WriteOptions # Get environment variables env = dict(os.environ) @@ -78,7 +77,7 @@ class UPSbattery(UPScommand): data = self.request(port=port, cmd="QBV") self.battV = float(data[0]) self.battPct = int(data[3]) - self.timeLeft = round(int(data[4]) / 60.0, 2) + self.timeLeft = round(int(data[4]) / 60.0, 1) ################## ###### MAIN ###### @@ -141,6 +140,7 @@ def main() -> int: ###### END MAIN LOOP ######### ############################## port.close() + write_client.close() LOGGER.warning("Main thread exited normally") return 0