diff --git a/sensors.py b/sensors.py index 63e7aaf..43a22c5 100644 --- a/sensors.py +++ b/sensors.py @@ -2,6 +2,7 @@ from time import perf_counter from datetime import datetime, timedelta from collections import deque import re +from os.path import exists # TODO client: add a way to disable live plotting? server: stop # sending data periodically to everybody! @@ -22,7 +23,6 @@ class Sensor(): class Temperature1W(Sensor): def __init__(self, address): - super().__init__() self.measure = 'Temperature' self.address = address @@ -30,7 +30,11 @@ class Temperature1W(Sensor): return f'/sys/bus/w1/devices/{self.address}/w1_slave' def read(self): - with open(self.path(), "r") as f: + path = self.path() + if not exists(path): + # WIP + return (perf_counter(), 0.0) + with open(path, "r") as f: content = f.readlines() time = perf_counter() if len(content) < 2: