change code to allow floats when sensor data is uneven

This commit is contained in:
WorldTeacher
2024-06-03 13:51:19 +02:00
parent 613bb2bdc6
commit be50b91feb

View File

@@ -64,14 +64,14 @@ class Transform:
on_state = len(sensor_data[date]["on"])
off_state = len(sensor_data[date]["off"])
activations = (on_state + off_state) / 2
if on_state != off_state:
# print("Error: On and off states are not equal", name, date)
tmp[name]["x"].append(date)
tmp[name]["y"].append(activations if activations > 1 else 0)
tmp[name]["y"].append(activations)
else:
# add the date to the tmp dictionary as x and the number of activations, divided by two as y
activations = (on_state + off_state) / 2
tmp[name]["x"].append(date)
tmp[name]["y"].append(activations if activations > 1 else 0)
# print(tmp)