Skip to content

Commit

Permalink
Handle case where startup fails to connect to spa
Browse files Browse the repository at this point in the history
  • Loading branch information
gazoodle committed Mar 15, 2022
1 parent 4a71895 commit aba5d52
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion custom_components/gecko/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .spa_manager import GeckoSpaManager
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import Config, HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady

from .const import (
CONF_SPA_ADDRESS,
Expand Down Expand Up @@ -82,7 +83,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
await spaman.__aenter__()
# We always wait for the facade because otherwise the
# device info is not available for the first entity
await spaman.wait_for_facade()
if not await spaman.wait_for_facade():
_LOGGER.error(
"Failed to connect to spa %s address %s", spa_identifier, spa_address
)
raise ConfigEntryNotReady

hass.data[DOMAIN][entry.entry_id] = spaman

entry.async_on_unload(entry.add_update_listener(async_reload_entry))
Expand Down

0 comments on commit aba5d52

Please sign in to comment.