syssi / homeassistant-goecharger-mqtt

go-eCharger integration for Home Assistant using the MQTT API
Apache License 2.0
75 stars 17 forks source link

ValueError with `ocu` #136

Closed MarkusMit closed 1 month ago

MarkusMit commented 4 months ago

Similar to clp (#110), I have a ValueError with sensor ocu in my logs:

ValueError: Sensor sensor.go_echarger_200xxx_ocu 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: '055.8, 056.1 BETA, V 055.0 OUTDATED, V 055.5 OUTDATED, V 055.7 OUTDATED' (<class 'str'>)

full log entry:

Logger: homeassistant.util.logging Source: util/logging.py:102 First occurred: 17:19:39 (2 occurrences) Last logged: 17:19:39

  • Exception in message_received when handling msg on '/go-eCharger/200xxx/clp': [...]
  • Exception in message_received when handling msg on '/go-eCharger/200xxx/ocu': '["055.8","056.1 BETA","V 055.0 OUTDATED","V 055.5 OUTDATED","V 055.7 OUTDATED"]' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 669, in state numerical_value = float(value) # type:ignore[arg-type] ^^^^^^^^^^^^ ValueError: could not convert string to float: '055.8, 056.1 BETA, V 055.0 OUTDATED, V 055.5 OUTDATED, V 055.7 OUTDATED' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/config/custom_components/goecharger_mqtt/sensor.py", line 97, in message_received self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 989, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1110, in _async_write_ha_state state, attr, capabilities, shadowed_attr = self.async_calculate_state() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1047, in async_calculate_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 995, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 671, in state raise ValueError( ValueError: Sensor sensor.go_echarger_200xxx_ocu 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: '055.8, 056.1 BETA, V 055.0 OUTDATED, V 055.5 OUTDATED, V 055.7 OUTDATED' (<class 'str'>)

Home Assistant

syssi commented 1 month ago

You update the integration to version 0.24.1.