Exception raised while updating state for `winddir`
Closed this issue · 2 comments
Anto79-ops commented
Hey!
thanks for the update. Just updated to 2024.6.0 and this is flooding my HA Core 2024.6.0b5 logs.
cheers
Logger: homeassistant.components.mqtt.models
Source: components/mqtt/models.py:380
integration: MQTT (documentation, issues)
First occurred: 9:54:40 PM (10 occurrences)
Last logged: 9:56:39 PM
Exception raised while updating state of sensor.gw2000_winddir_name, topic: 'homeassistant/sensor/[REDACTED]/winddir_name/state' with payload: b'NW'
Exception raised while updating state of sensor.gw1100_winddir_name, topic: 'homeassistant/sensor/[REDACTED]/winddir_name/state' with payload: b'N'
Exception raised while updating state of sensor.gw1100_winddir_name, topic: 'homeassistant/sensor/[REDACTED]/winddir_name/state' with payload: b'NNW'
Exception raised while updating state of sensor.gw1100_winddir_name, topic: 'homeassistant/sensor/[REDACTED]/winddir_name/state' with payload: b'ENE'
Exception raised while updating state of sensor.gw2000_winddir_name, topic: 'homeassistant/sensor/[REDACTED]/winddir_name/state' with payload: b'NNW'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 658, in state
numerical_value = int(value)
^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'N'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 661, in state
numerical_value = float(value)
^^^^^^^^^^^^
ValueError: could not convert string to float: 'N'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/mqtt/models.py", line 380, in process_write_state_requests
entity.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1000, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1126, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1061, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1006, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 665, in state
raise ValueError(
ValueError: Sensor sensor.gw2000_winddir_name has device class 'None', state class 'measurement' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'N' (<class 'str'>)
bachya commented
Thanks, @Anto79-ops! Just cut 2024.06.1, which includes a fix for this.
Anto79-ops commented
thank you! that seems to have fixed it: the new entity is now reporting wind direction, and my logs have stopped logging the above error.
Cheers bud