HomeAssistant-OctopusEnergy: ValueError since 9.0.0

Describe the bug

Haven’t yet checked the UI, but my Home Assistant log is being spammed with the below since upgrading to 9.0.0:

homeassistant                      | 2023-11-21 15:23:28.674 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
homeassistant                      | Traceback (most recent call last):
homeassistant                      |   File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 616, in state
homeassistant                      |     numerical_value = int(value)
homeassistant                      |                       ^^^^^^^^^^
homeassistant                      | ValueError: invalid literal for int() with base 10: 'unknown'
homeassistant                      | 
homeassistant                      | During handling of the above exception, another exception occurred:
homeassistant                      | 
homeassistant                      | Traceback (most recent call last):
homeassistant                      |   File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 619, in state
homeassistant                      |     numerical_value = float(value)
homeassistant                      |                       ^^^^^^^^^^^^
homeassistant                      | ValueError: could not convert string to float: 'unknown'
homeassistant                      | 
homeassistant                      | The above exception was the direct cause of the following exception:
homeassistant                      | 
homeassistant                      | Traceback (most recent call last):
homeassistant                      |   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 233, in _handle_refresh_interval
homeassistant                      |     await self._async_refresh(log_failures=True, scheduled=True)
homeassistant                      |   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 389, in _async_refresh
homeassistant                      |     self.async_update_listeners()
homeassistant                      |   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 172, in async_update_listeners
homeassistant                      |     update_callback()
homeassistant                      |   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 469, in _handle_coordinator_update
homeassistant                      |     self.async_write_ha_state()
homeassistant                      |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 743, in async_write_ha_state
homeassistant                      |     self._async_write_ha_state()
homeassistant                      |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 843, in _async_write_ha_state
homeassistant                      |     state, attr = self._async_generate_attributes()
homeassistant                      |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant                      |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 784, in _async_generate_attributes
homeassistant                      |     state = self._stringify_state(available)
homeassistant                      |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant                      |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 749, in _stringify_state
homeassistant                      |     if (state := self.state) is None:
homeassistant                      |                  ^^^^^^^^^^
homeassistant                      |   File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 623, in state
homeassistant                      |     raise ValueError(
homeassistant                      | ValueError: Sensor sensor.octopus_energy_gas_e6s07830951656_1474688906_previous_accumulative_consumption_kwh has device class 'energy', state class 'total' unit 'kWh' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unknown' (<class 'str'>)

Let me know if you need any further information.

Regards

Reproduction steps

None

Expected behaviour

No Error

Tariff Code

No response

Integration Version

9.0.0

Home Assistant Version

2023.11.2

Fresh Install?

After upgrading

Home Assistant Logs

homeassistant | 2023-11-21 15:23:28.674 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved homeassistant | Traceback (most recent call last): homeassistant | File “/usr/src/homeassistant/homeassistant/components/sensor/init.py”, line 616, in state homeassistant | numerical_value = int(value) homeassistant | ^^^^^^^^^^ homeassistant | ValueError: invalid literal for int() with base 10: ‘unknown’ homeassistant | homeassistant | During handling of the above exception, another exception occurred: homeassistant | homeassistant | Traceback (most recent call last): homeassistant | File “/usr/src/homeassistant/homeassistant/components/sensor/init.py”, line 619, in state homeassistant | numerical_value = float(value) homeassistant | ^^^^^^^^^^^^ homeassistant | ValueError: could not convert string to float: ‘unknown’ homeassistant | homeassistant | The above exception was the direct cause of the following exception: homeassistant | homeassistant | Traceback (most recent call last): homeassistant | File “/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py”, line 233, in _handle_refresh_interval homeassistant | await self._async_refresh(log_failures=True, scheduled=True) homeassistant | File “/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py”, line 389, in _async_refresh homeassistant | self.async_update_listeners() homeassistant | File “/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py”, line 172, in async_update_listeners homeassistant | update_callback() homeassistant | File “/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py”, line 469, in _handle_coordinator_update homeassistant | self.async_write_ha_state() homeassistant | File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 743, in async_write_ha_state homeassistant | self._async_write_ha_state() homeassistant | File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 843, in _async_write_ha_state homeassistant | state, attr = self._async_generate_attributes() homeassistant | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ homeassistant | File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 784, in _async_generate_attributes homeassistant | state = self._stringify_state(available) homeassistant | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ homeassistant | File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 749, in _stringify_state homeassistant | if (state := self.state) is None: homeassistant | ^^^^^^^^^^ homeassistant | File “/usr/src/homeassistant/homeassistant/components/sensor/init.py”, line 623, in state homeassistant | raise ValueError( homeassistant | ValueError: Sensor sensor.octopus_energy_gas_e6s07830951656_1474688906_previous_accumulative_consumption_kwh has device class ‘energy’, state class ‘total’ unit ‘kWh’ and suggested precision ‘None’ thus indicating it has a numeric value; however, it has the non-numeric value: ‘unknown’ (<class ‘str’>)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Thanks for that - confirms my suspicions, I just need to work out how to confirm locally. The inclusion of last updated timestamp and last evaluated is a bug, which I’ll also fix.