master
Nicolò Balzarotti 2022-11-19 19:25:46 +01:00
parent f216ebd6db
commit f7491bb79b
1 changed files with 6 additions and 2 deletions

View File

@ -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: