Skip to content

Commit a18550d

Browse files
authored
Merge pull request #81 from alepee/claude/plan-next-steps-wvyED
2 parents 8083612 + 274a04b commit a18550d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

custom_components/heating_cooling_degree_days/calculations.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,14 @@ async def get_temperature_readings(
221221
invalid_states = 0
222222

223223
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:
224+
if state.state in ("unknown", "unavailable"):
225+
invalid_states += 1
226+
continue
227+
228+
try:
229+
temp_value = float(state.state)
230+
readings.append((state.last_updated, temp_value))
231+
except (ValueError, TypeError):
230232
invalid_states += 1
231233

232234
if invalid_states:

0 commit comments

Comments
 (0)