Skip to content

Commit

Permalink
fix: Raise error on startup if account information is not available, …
Browse files Browse the repository at this point in the history
…which will cause HA to retry
  • Loading branch information
BottlecapDave committed Sep 17, 2023
1 parent 488ba94 commit 4799400
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 3 additions & 1 deletion custom_components/octopus_energy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async def async_setup_entry(hass, entry):
)
elif CONFIG_TARGET_NAME in config:
if DOMAIN not in hass.data or DATA_ELECTRICITY_RATES_COORDINATOR not in hass.data[DOMAIN] or DATA_ACCOUNT not in hass.data[DOMAIN]:
raise ConfigEntryNotReady
raise ConfigEntryNotReady("Electricity rates have not been setup")

# Forward our entry to setup our target rate sensors
hass.async_create_task(
Expand Down Expand Up @@ -101,6 +101,8 @@ async def async_setup_dependencies(hass, config):
hass.data[DOMAIN][DATA_ACCOUNT_ID] = config[CONFIG_MAIN_ACCOUNT_ID]

account_info = await client.async_get_account(config[CONFIG_MAIN_ACCOUNT_ID])
if (account_info is None):
raise ConfigEntryNotReady(f"Failed to retrieve account information")

hass.data[DOMAIN][DATA_ACCOUNT] = account_info

Expand Down
5 changes: 0 additions & 5 deletions custom_components/octopus_energy/target_rates/target_rate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging

import re
import voluptuous as vol

from homeassistant.core import HomeAssistant, callback
Expand Down Expand Up @@ -29,10 +28,6 @@
CONFIG_TARGET_OFFSET,
DATA_ACCOUNT,
DOMAIN,

REGEX_HOURS,
REGEX_TIME,
REGEX_OFFSET_PARTS,
)

from . import (
Expand Down

0 comments on commit 4799400

Please sign in to comment.