BottlecapDave / HomeAssistant-OctopusEnergy

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

Intergration stopped working #64

Closed davelegg83 closed 1 year ago

davelegg83 commented 1 year ago

For some reason the intergration seems to have stopped working. When I click on one of the entities it says 'This entity is no longer being provided by the octopus_energy integration. If the entity is no longer in use, delete it in settings.' I tried uninstalling and re-installing, however after putting in the API key and account, It just says 'Unknown error occured'

Looking at the logs it says: `Logger: custom_components.octopus_energy Source: custom_components/octopus_energy/api_client.py:120 Integration: Octopus Energy (documentation, issues) First occurred: 07:29:14 (1 occurrences) Last logged: 07:29:14 Unexpected error fetching rates data: 'NoneType' object is not subscriptable

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh self.data = await self._async_update_data() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 164, in _async_update_data return await self.update_method() File "/config/custom_components/octopus_energy/init.py", line 79, in async_update_electricity_rates_data tariff_codes = await async_get_current_electricity_agreement_tariff_codes(client, config) File "/config/custom_components/octopus_energy/init.py", line 54, in async_get_current_electricity_agreement_tariff_codes account_info = await client.async_get_account(config[CONFIG_MAIN_ACCOUNT_ID]) File "/config/custom_components/octopus_energy/api_client.py", line 112, in async_get_account "gas_meter_points": list(map(lambda mp: { File "/config/custom_components/octopus_energy/api_client.py", line 117, in "agreements": list(map(lambda a: { File "/config/custom_components/octopus_energy/api_client.py", line 120, in "tariff_code": a["tariff"]["tariffCode"], TypeError: 'NoneType' object is not subscriptable`

and

`Logger: homeassistant.components.sensor Source: helpers/update_coordinator.py:178 Integration: Sensor (documentation, issues) First occurred: 07:29:14 (1 occurrences) Last logged: 07:29:14 Error while setting up octopus_energy platform for sensor

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh self.data = await self._async_update_data() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 164, in _async_update_data return await self.update_method() File "/config/custom_components/octopus_energy/init.py", line 79, in async_update_electricity_rates_data tariff_codes = await async_get_current_electricity_agreement_tariff_codes(client, config) File "/config/custom_components/octopus_energy/init.py", line 54, in async_get_current_electricity_agreement_tariff_codes account_info = await client.async_get_account(config[CONFIG_MAIN_ACCOUNT_ID]) File "/config/custom_components/octopus_energy/api_client.py", line 112, in async_get_account "gas_meter_points": list(map(lambda mp: { File "/config/custom_components/octopus_energy/api_client.py", line 117, in "agreements": list(map(lambda a: { File "/config/custom_components/octopus_energy/api_client.py", line 120, in "tariff_code": a["tariff"]["tariffCode"], TypeError: 'NoneType' object is not subscriptable

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 281, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/octopus_energy/sensor.py", line 97, in async_setup_entry await async_setup_default_sensors(hass, entry, async_add_entities) File "/config/custom_components/octopus_energy/sensor.py", line 113, in async_setup_default_sensors await rate_coordinator.async_config_entry_first_refresh() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 178, in async_config_entry_first_refresh raise ex homeassistant.exceptions.ConfigEntryNotReady: 'NoneType' object is not subscriptable`

Hoping you might be able to help.

davelegg83 commented 1 year ago

Everything has started working again!

BottlecapDave commented 1 year ago

Interesting. A similar issue has been reported in https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/issues/62. The fact it's working again and I haven't seen this issue suggests it might be an intermitent issue.

Do you have the ability to set your log level to 'debug' and try again? This should add the raw response to your home assistant logs when you attempt again. This will hopefully help guide why you received this error.

craigrouse commented 1 year ago

I've seen this happen a few times in the past, but today it was for a prolonged period. I didn't have debug logging on, but the logs would suggest that an incomplete (or empty) response was received from the Octopus API. Looking at the code, it seemed to me that it was in the response processing block, which would suggest that it had indeed received a response, but the "tariff" part of the response was missing. I may be wrong of course - this was just from a quick glance at the error and the python code.

BottlecapDave commented 1 year ago

It looks like this. I'm curious why this is happening "randomly", which was why I was wondering if it was possible for you to post the raw request when it occurs as that might shed some light on the situation. I'm guessing that the order of tariffs returned isn't deterministic.

github-actions[bot] commented 1 year ago

This issue has become stale because it has been open for 30 days with no activity. If you still think it's an issue, please respond soon.

github-actions[bot] commented 1 year ago

This issue has been closed because it has been inactive for 14 days since being marked as stale. This is done to help keep on top of active issues. If you still think it's an issue, please respond to this issue