fix 1W sensor reading

This commit is contained in:
Nicolò Balzarotti 2022-11-19 19:04:56 +01:00
parent c45114f6f7
commit 14e4628727
1 changed files with 2 additions and 1 deletions

View File

@ -32,12 +32,13 @@ class Temperature1W(Sensor):
def read(self):
with open(self.path(), "r") as f:
content = f.readlines()
time = perf_counter()
if len(content) < 2:
return None
if content[0].strip()[-3:] != "YES":
print("INVALID CHECKSUM")
return None
return int(re.search("t=([0-9]+)", content[1]).group(1)) / 1000.0
return (time, int(re.search("t=([0-9]+)", content[1]).group(1)) / 1000.0)
class Sensors():
def __init__(self, history=2621440):