BottlecapDave / HomeAssistant-OctopusEnergy

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

error fetching current_consumption #802

Closed stefano-bortolotti closed 2 months ago

stefano-bortolotti commented 3 months ago

Describe the bug

The current_consumption sensor is not reporting data anymore. I tested the octopus mini via the main Octopus App and the live consumption is reported correctly. Looking at HomeAssistant logs I see multiple errors indicating the sensor is not reporting the correct data.

Reproduction steps

Via the developer tools reading the value of the “current_consumption” entity returns “unavailable”.

Expected behaviour

It should return a number with the current consumption.

Tariff Code

E-1R-AGILE-23-12-06-A

Integration Version

10.1.4

Home Assistant Version

2024.3

Fresh Install?

After upgrading

Home Assistant Logs

Logger: custom_components.octopus_energy.coordinators.current_consumption
Source: helpers/update_coordinator.py:318
integration: Octopus Energy ([documentation](https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy), [issues](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/issues))
First occurred: 17 March 2024 at 18:22:25 (654 occurrences)
Last logged: 21:59:03

Unexpected error fetching current_consumption_00-1D-24-02-01-16-98-F2 data: float() argument must be a string or a real number, not 'NoneType'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 318, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 274, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/octopus_energy/coordinators/current_consumption.py", line 81, in async_update_data
    hass.data[DOMAIN][account_id][key] = await async_get_live_consumption(
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/octopus_energy/coordinators/current_consumption.py", line 39, in async_get_live_consumption
    data = await client.async_get_smart_meter_consumption(device_id, period_from, period_to)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/octopus_energy/api_client/__init__.py", line 660, in async_get_smart_meter_consumption
    return list(map(lambda mp: {
           ^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/octopus_energy/api_client/__init__.py", line 661, in <lambda>
    "consumption": float(mp["consumptionDelta"]) / 1000,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: float() argument must be a string or a real number, not 'NoneType'

Confirmation

BottlecapDave commented 2 months ago

Hello and sorry for the late response.

This should be fixed in the latest release (v10.2.0)