CestLaGalere / mobilealerts

Retrieves sensor data for Mobile Alerts sensors for Home Assistant
Apache License 2.0
15 stars 6 forks source link

could not convert string to float: seems to get unreliable data from API causing an error and stop working afterwards ... #20

Closed helmut-hackl closed 4 months ago

helmut-hackl commented 7 months ago
Logger: homeassistant
Source: custom_components/mobile_alerts/sensor.py:255
Integration: mobile alerts ([documentation](https://github.com/cestlagalere/mobilealerts), [issues](https://github.com/cestlagalere/mobilealerts/issues))
First occurred: 29. Januar 2024 um 16:30:09 (83 occurrences)
Last logged: 06:21:21

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 243, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 399, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 182, in async_update_listeners
    update_callback()
  File "/config/custom_components/mobile_alerts/sensor.py", line 200, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 945, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1066, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1003, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 951, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 524, in state
    value = self.native_value
            ^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mobile_alerts/sensor.py", line 255, in native_value
    val = float(self._attr_native_value)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: 'unknown'
petrleocompel commented 4 months ago

Closed with last commit. This report is from older version of integration but added error handle for parsing.