HomeAssistant-OctopusEnergy: Unable to connect

Describe the bug

Upon upgrading to the latest version and after numerous restarts, I keep getting an error about unable to connect with a timeout error. Interestingly, the Gas stats seem to work. It’s just for Electric.

Reproduction steps

Upgrade from an older Octopus version to the latest.

Expected behaviour

I expect it to work as before.

Tariff Code

Unknown

Integration Version

Latest

Home Assistant Version

Latest

Fresh Install?

After upgrading

Home Assistant Logs

2023-12-31 19:39:05.705 WARNING (MainThread) [custom_components.octopus_energy.api_client] Failed to connect. Timeout of ClientTimeout(total=15, connect=None, sock_read=None, sock_connect=None, ceil_threshold=5) exceeded.
2023-12-31 19:39:05.706 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry A-0000C00E for octopus_energy
Traceback (most recent call last):
  File "/config/custom_components/octopus_energy/api_client/__init__.py", line 393, in async_refresh_token
    async with client.post(url, json=payload) as token_response:
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 1187, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 601, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 960, in start
    with self._timer:
  File "/usr/local/lib/python3.11/site-packages/aiohttp/helpers.py", line 735, in __exit__
    raise asyncio.TimeoutError from None
TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 402, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/octopus_energy/__init__.py", line 83, in async_setup_entry
    await async_setup_dependencies(hass, config)
  File "/config/custom_components/octopus_energy/__init__.py", line 128, in async_setup_dependencies
    account_info = await client.async_get_account(config[CONFIG_MAIN_ACCOUNT_ID])
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/octopus_energy/api_client/__init__.py", line 411, in async_get_account
    await self.async_refresh_token()
  File "/config/custom_components/octopus_energy/api_client/__init__.py", line 407, in async_refresh_token
    raise TimeoutException()
custom_components.octopus_energy.api_client.TimeoutException 

Also I get the two lines:

2023-12-31 20:01:38.636 WARNING (MainThread) [custom_components.octopus_energy.coordinators.intelligent_dispatches] Failed to retrieve new dispatches. Next attempt at 2023-12-31 20:02:38.635948+00:00
2023-12-31 20:01:38.638 WARNING (MainThread) [custom_components.octopus_energy.coordinators.intelligent_settings] Failed to retrieve new intelligent settings. Next attempt at 2023-12-31 20:02:38.637731+00:00

Confirmation

  • I confirm that I cannot find my solution within the documentation
  • I confirm that I cannot find my solution within the FAQ

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Comments: 27 (5 by maintainers)

Most upvoted comments

Hello. Sorry for the late response. Timeout exceptions unfortunately are something that can’t be fixed on my end other than increasing the timeout, but this doesn’t guarantee success and results in HA reporting slow integration warnings which I then have issues raised against too (lose lose situation 😃)

The integration uses a variety of octopus APIs, both rest and graphql (the latter being more fully fledged) and I’m assuming they’re using a microservice architecture. This means that one of the API commands can be functional while other parts aren’t.

Based on reports in the OE forums it looks like other people had various API issues.

A future update will reduce the hit on the API during startup, which will hopefully help make it more stable.

If it helps, i’ve just created this automation to try and restart the integration if it’s unavailable. I initially did it based on the state change, but then it doesn’t retry later if it fails on first restart. This checks the integration state every 15 minutes and reloads if req’d.

description: Force restart of Octopus Integration if it becomes unavailable.
trigger:
  - alias: Check Octopus Integration State every 15 minutes
    platform: time_pattern
    minutes: /15
condition:
  - condition: state
    entity_id: binary_sensor.octopus_energy_a_cXXXXXX_intelligent_dispatching
    state: unavailable
    alias: Check to see if Intelligent Dispatching is Unavailable
action:
  - service: homeassistant.reload_config_entry
    target:
      entity_id: binary_sensor.octopus_energy_a_cXXXXXX_intelligent_dispatching
    data: {}
    alias: Reload Octopus Integration if Intelligent Dispatching is Unavailable
mode: restart

Awesome thank you for that!

If it helps, i’ve just created this automation to try and restart the integration if it’s unavailable. I initially did it based on the state change, but then it doesn’t retry later if it fails on first restart. This checks the integration state every 15 minutes and reloads if req’d.

description: Force restart of Octopus Integration if it becomes unavailable.
trigger:
  - alias: Check Octopus Integration State every 15 minutes
    platform: time_pattern
    minutes: /15
condition:
  - condition: state
    entity_id: binary_sensor.octopus_energy_a_cXXXXXX_intelligent_dispatching
    state: unavailable
    alias: Check to see if Intelligent Dispatching is Unavailable
action:
  - service: homeassistant.reload_config_entry
    target:
      entity_id: binary_sensor.octopus_energy_a_cXXXXXX_intelligent_dispatching
    data: {}
    alias: Reload Octopus Integration if Intelligent Dispatching is Unavailable
mode: restart

I’m seeing similar in the app, I can see import usage for today but export and everything is is blank. My Home Mini data is coming through but inconsistently, seems to work fine for 5 minutes or so then reports that it’s no longer being reported, then comes back again without me doing anything.

My gut feeling is that there is an issue on the Octopus side, I’d imagine some young project manager somewhere thought that making system upgrades on New Years Day was a super idea 😃

Ive tried re-installing the intergration and nothing works. I have no access to my octopus data at all.

Im also getting no connection to octopus energy/home mini, it keeps saying failed to set-up.

Numerous restarts and reloads, but nothing. Octopus live app is working and receiving data from my home mini