diff --git a/custom_components/illuminance/sensor.py b/custom_components/illuminance/sensor.py index 8a24c5c..87f4b03 100644 --- a/custom_components/illuminance/sensor.py +++ b/custom_components/illuminance/sensor.py @@ -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, )