You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hackspaceapi/spaceapi.py
+15-3Lines changed: 15 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -63,10 +63,18 @@ def get_sensors() -> dict:
63
63
64
64
# Handle entities with temp attributes
65
65
if"temperature"indata["attributes"]:
66
-
value=float(data["attributes"]["temperature"])
66
+
try:
67
+
value=float(data["attributes"]["temperature"])
68
+
exceptValueError:
69
+
logging.warning("Failed to convert '{0}' to float, so skipping sensor {1}".format(data["attributes"]["temperature"], sensor.locationordata["attributes"]["friendly_name"]))
70
+
continue
67
71
unit_val=data["attributes"]["temperature_unit"]
68
72
else:
69
-
value=float(data["state"])
73
+
try:
74
+
value=float(data["state"])
75
+
exceptValueError:
76
+
logging.warning("Failed to convert '{0}' to float, so skipping sensor {1}".format(data["state"], sensor.locationordata["attributes"]["friendly_name"]))
unit_val="%"# Humidity attributes generally don't have a unit value, assume %
93
101
else:
94
-
value=float(data["state"])
102
+
try:
103
+
value=float(data["state"])
104
+
exceptValueError:
105
+
logging.warning("Failed to convert '{0}' to float, so skipping sensor {1}".format(data["state"], sensor.locationordata["attributes"]["friendly_name"]))
0 commit comments