Skip to content

Commit

Permalink
Clamp cloud coverage values to 0 - 100 without logging error (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
pnbruckner authored Apr 23, 2024
1 parent 5d2e80c commit 03748d8
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions custom_components/illuminance/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,10 @@ def _get_divisor_from_weather_data(self, entity_state: State | None) -> None:

if self._entity_status == EntityStatus.OK_CLOUD:
try:
cloud = float(condition)
if not 0 <= cloud <= 100:
raise ValueError
cloud = min(max(0, float(condition)), 100)
except ValueError:
_LOGGER.error(
"%s: Cloud coverage sensor state "
"is not a number between 0 and 100: %s",
"%s: Cloud coverage sensor state is not a number: %s",
self.name,
condition,
)
Expand Down

0 comments on commit 03748d8

Please sign in to comment.