Skip to content

Commit

Permalink
Fix float conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Marc Collin committed Jun 13, 2023
1 parent 8a6dadf commit ae614db
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion custom_components/solar_optimizer/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_safe_float(hass, entity_id: str):
"""Get a safe float state value for an entity.
Return None if entity is not available"""
state = hass.states.get(entity_id)
if not state:
if not state or state.state == "unknown" or state.state == "unavailable":
return None
float_val = float(state.state)
return None if math.isinf(float_val) or not math.isfinite(float_val) else float_val
Expand Down

0 comments on commit ae614db

Please sign in to comment.