BottlecapDave / HomeAssistant-OctopusEnergy

Unofficial Home Assistant integration for interacting with Octopus Energy
https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/
MIT License
535 stars 50 forks source link

Previous accumulative consumption no longer provided by integration #718

Closed FiveVoltLogic closed 5 months ago

FiveVoltLogic commented 5 months ago

Describe the bug

I noticed today that previous accumulated cost and previous accumulated consumption were no longer being reported. According to the history this occured at 13:25 yesterday (21st Jan) the previous update to the sensors was at 9:55 on the same day.

I am still receiving the correct values in the Octopus app which has updated as usual

Reproduction steps

Unsure but I have since re enabled all the sensors since reading the post about the current accumulative consumption. I have updated to the latest version and also updated HA itself to the latest version

Expected behaviour

That the previous accumulative cost and consumption sensors report to HA

Tariff Code

E-1R-LOYAL-FIX-12M-23-12-08-H

Integration Version

10.0.3

Home Assistant Version

2024.1.5 Core - 11.4 OS

Fresh Install?

Not specified

Home Assistant Logs

Just these which seem to be related to the sensor giving a state of 'unknown'

Log Entry 1

Logger: homeassistant.components.sensor Source: helpers/entity_platform.py:368 Integration: Sensor (documentation, issues) First occurred: 15:57:24 (1 occurrences) Last logged: 15:57:24

Error while setting up octopus_energy platform for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 644, in state numerical_value = float(value) # type:ignore[arg-type] ^^^^^^^^^^^^ ValueError: could not convert string to float: 'unavailable'

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

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 368, in _async_setup_platform await asyncio.gather(pending) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities await asyncio.gather(tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1282, in add_to_platform_finish 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 646, in state raise ValueError( ValueError: Sensor sensor.octopus_energy_electricity2[redacted][redacted]_previous_accumulative_consumption 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: 'unavailable' (<class 'str'>)

Log Entry 2

Logger: homeassistant.components.sensor Source: helpers/entity_platform.py:507 Integration: Sensor (documentation, issues) First occurred: 15:57:24 (1 occurrences) Last logged: 15:57:24

Error adding entities for domain sensor with platform octopus_energy Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 644, in state numerical_value = float(value) # type:ignore[arg-type] ^^^^^^^^^^^^ ValueError: could not convert string to float: 'unavailable'

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

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1282, in add_to_platform_finish 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 646, in state raise ValueError( ValueError: Sensor sensor.octopus_energyelectricity[redacted]_[redacted]_previous_accumulative_consumption 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: 'unavailable' (<class 'str'>)

Confirmation

BottlecapDave commented 5 months ago

Hello. Sorry that you're receiving this error. I'll try and get a fix out by the end of next week. If you can't wait that long and you're able to access .storage\core.restore_state, you should be able to correct this mistake within this file by finding the target entity and updating the state to "unknown" while HA is restarting.

FiveVoltLogic commented 5 months ago

No problem!

Thanks for your quick reply and massive thanks for all the hard work you put in with the integration!

Being able to automate the saving sessions has been a massive help this winter as we moved to an all electric house - it is the future but fudge me it's bloody expensive!

Anyway, you kind of just reminded me to pass on some of the savings as well.

I'll look into the fix you mentioned but will probably wait for the fix. If you need anything else from me, just shout :)

BottlecapDave commented 5 months ago

Thank you for the kind words and sponsorship

BottlecapDave commented 5 months ago

This should now be fixed in 10.0.4

FiveVoltLogic commented 4 months ago

Thanks for your hard work!