BottlecapDave / HomeAssistant-OctopusEnergy

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

Integration fails to initialize with unknown tariff #883

Closed ChrisWarwick closed 2 weeks ago

ChrisWarwick commented 1 month ago

Describe the bug

Integration initialization failure caused by error:

 Exception: Failed to retrieve rates for tariff 'BUS-PANELP-12M-FIXED-SEPTEMBER2029'

I'm guessing the tariff isn't found for some reason? (It is valid) Background: this is the "PanelPower" business tariff (the small business version of the Octopus Export tariff)

Please let me know if you need further information or if I can help in any way with diagnosis.

Reproduction steps

Restart the integration. The error occurs. I've tried uninstalling and re-installing the integration.

Expected behaviour

The integration should retrieve the tariff information

Tariff Code

BUS-PANELP-12M-FIXED-SEPTEMBER2029

Integration Version

11.0.2

Home Assistant Version

HAOS 12.3 (Core 2024.5.4, Supervisor 2024.01.1)

Fresh Install?

Not specified

Home Assistant Logs

Logger: homeassistant.components.sensor Source: helpers/entity_platform.py:356 integration: Sensor (documentation, issues) First occurred: May 22, 2024 at 3:05:04 PM (1 occurrences) Last logged: May 22, 2024 at 3:05:04 PM

Error while setting up octopus_energy platform for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform await asyncio.shield(awaitable) File "/config/custom_components/octopus_energy/sensor.py", line 108, in async_setup_entry await async_setup_default_sensors(hass, config, async_add_entities) File "/config/custom_components/octopus_energy/sensor.py", line 279, in async_setup_default_sensors total_unique_rates = await get_unique_electricity_rates(hass, client, electricity_tariff_code if tariff_override is None else tariff_override) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/octopus_energy/sensor.py", line 92, in get_unique_electricity_rates raise Exception(f"Failed to retrieve rates for tariff '{tariff_code}'") Exception: Failed to retrieve rates for tariff 'BUS-PANELP-12M-FIXED-SEPTEMBER2029'

Confirmation

BottlecapDave commented 1 month ago

Hello and sorry you're seeing this issue. Unfortunately, it looks like business based tariffs don't follow the usual structure which is causing this issue. There should be a repair notice to indicate this, but it looks like this is breaking before that is reached now.

When I get some time, I'll see if I can support business tariffs, but a lot of the code base relied on a the predetermined well formed structure

ChrisWarwick commented 1 month ago

Hi Dave - thanks for looking into this. Trust me to be an edge-case! Very happy to help if I can. This is a three-phase supply with the "Green Octopus 36M Fixed" import tariff. The integration was working fine, including the Octopus Mini, until we got our export tariff enabled. If it's tricky to support the business export tariffs would it be possible to just ignore the error and continue to work with just the import numbers? Or to have manual input of the export rate (which is the standard Octopus 15p/kWh continuously) - although I appreciate that would probably be even more code changes... Thanks anyway :-) Chris PS. Happily using the integration at home on Intelligent Go without issues :-)

BottlecapDave commented 1 month ago

I'll try and fix the repair notice issue, and update to ignore the offending entities if it can't be determined as a short term "fix".

BottlecapDave commented 2 weeks ago

Sorry for the late response. The integration should now hopefully support business tariffs as part of v11.1.0.

ChrisWarwick commented 2 weeks ago

Awesome - fab. Thank you. Installing now and will report back....

ChrisWarwick commented 2 weeks ago

All looks good Dave - thank you so much :-)