fix percent calculation

This commit is contained in:
Andrew de Quincey 2021-05-01 20:27:48 +01:00
parent 83512b1faf
commit ec3c825e8e

View File

@ -128,7 +128,10 @@ class TempSensorReal(TempSensor):
while True:
# reset error counter if time is up
if (time.time() - self.bad_stamp) > (self.time_step * 2):
self.bad_percent = (self.bad_count / (self.bad_count + self.ok_count)) * 100
if self.bad_count + self.ok_count:
self.bad_percent = (self.bad_count / (self.bad_count + self.ok_count)) * 100
else:
self.bad_percent = 0
self.bad_count = 0
self.ok_count = 0
self.bad_stamp = time.time()