basbruss / adaptive-cover

An Adaptive Cover component for HomeAsisstant to control covers based on the sun's position
MIT License
50 stars 7 forks source link

Error during initialization when lux sensor is configured #234

Open dieneuser opened 2 weeks ago

dieneuser commented 2 weeks ago

What version of Adaptive Cover are you using?

1.3.2

What version of Home Assistant are you using?

2024.6.4

Checklist

Describe the issue

Once I have configured my Lux sensor, the integration works as intended until I restart Home Assistant. The integration probably starts faster than the sensor (Z2MQTT) is ready and an error occurs during initialization:

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.adaptive_cover
Quelle: helpers/update_coordinator.py:312
Integration: Adaptive Cover (Dokumentation, Probleme)
Erstmals aufgetreten: 10:28:40 (14 Vorkommnisse)
Zuletzt protokolliert: 10:29:53

Unexpected error fetching adaptive_cover data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_cover/coordinator.py", line 225, in _async_update_data
    self.climate_mode_data(options, cover_data)
  File "/config/custom_components/adaptive_cover/coordinator.py", line 557, in climate_mode_data
    self.climate_state = round(ClimateCoverState(cover_data, climate).get_state())
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_cover/calculation.py", line 388, in get_state
    result = self.normal_type_cover()
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_cover/calculation.py", line 316, in normal_type_cover
    return self.normal_with_presence()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_cover/calculation.py", line 325, in normal_with_presence
    self.climate_data.lux
  File "/config/custom_components/adaptive_cover/calculation.py", line 293, in lux
    return float(value) <= self.lux_threshold
           ^^^^^^^^^^^^
TypeError: float() argument must be a string or a real number, not 'NoneType'

After that, the Lux function is not available. Only when I manually reload the integration does everything work as intended.

Reproduction steps

  1. Configure Lux sensor
  2. Restart HA
  3. The error described occurs

Diagnostics dump

No response