mega_hacs icon indicating copy to clipboard operation
mega_hacs copied to clipboard

Не отображаются актуальные данные датчиков i2c

Open wji9na opened this issue 5 months ago • 1 comments

Описание После обновления HomeAssistant перестали отображаться актуальные данные датчиков i2c, данные судя по дебагу поступают от датчиков, но не отображаются в карточке и состоянии датчика. Эта проблема появилась достаточно давно, поэтому я тянул с обновлением, но больше откладывать не мог. На скриншоте видно частоту обновления информации до обновления HA и после. При этом один датчик продолжает обновляться как ни в чём ни бывало.

Версии систем Enviroment: homeassistantos/proxmoxve HA version: 11.3 mega_hacs version: 1.1.7 megad firmware version: 4.51b2 используется mqtt: false

Ожидаемое поведение Обновление данных датчика каждые 30 секунд, в соответствии с настройками обновления входов интеграции.

Screenshots не отображающийся корректно датчик image единственный отображающийся датчик image

LOG пример получения данных от датчика, значения которого не обновляются корректно, после обновления:

2024-01-10 10:09:11.291 DEBUG (MainThread) [custom_components.mega.mega] request: http://192.168.1.1/sec/?pt=43&scl=30&i2c_dev=htu21d&i2c_par=1
2024-01-10 10:09:11.351 DEBUG (MainThread) [custom_components.mega.mega] response -7.96
2024-01-10 10:09:11.351 DEBUG (MainThread) [custom_components.mega.mega] i2c response: {(('pt', '43'), ('scl', '30'), ('i2c_dev', 'htu21d'), ('i2c_par', 1)): '-7.96'}

в конце процедуры обновления входов от меги в логе присутствует ошибка:

2024-01-10 10:09:11.446 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 639, in state
    numerical_value = int(value)
                      ^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'NA'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 642, in state
    numerical_value = float(value)
                      ^^^^^^^^^^^^
ValueError: could not convert string to float: 'NA'

The above exception was the direct cause of the following exception:

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 "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 479, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 941, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1062, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 999, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 947, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 646, in state
    raise ValueError(
ValueError: Sensor sensor.mega_31_htu21d_temperature has device class 'temperature', state class 'None' unit '°C' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'NA' (<class 'str'>)

wji9na avatar Jan 10 '24 07:01 wji9na