We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 8083612 + 274a04b commit a18550dCopy full SHA for a18550d
custom_components/heating_cooling_degree_days/calculations.py
@@ -221,12 +221,14 @@ async def get_temperature_readings(
221
invalid_states = 0
222
223
for state in temp_history[entity_id]:
224
- if (
225
- state.state not in ("unknown", "unavailable")
226
- and state.state.replace(".", "", 1).isdigit()
227
- ):
228
- readings.append((state.last_updated, float(state.state)))
229
- else:
+ if state.state in ("unknown", "unavailable"):
+ invalid_states += 1
+ continue
+
+ try:
+ temp_value = float(state.state)
230
+ readings.append((state.last_updated, temp_value))
231
+ except (ValueError, TypeError):
232
invalid_states += 1
233
234
if invalid_states:
0 commit comments