Skip to content

Commit

Permalink
add more logging during setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarv committed Jan 5, 2024
1 parent 75945f7 commit 96a056a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions custom_components/bwt_perla/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""The BWT Perla integration."""

import logging

from bwt_api.api import BwtApi
from bwt_api.exception import BwtException

Expand All @@ -10,6 +12,7 @@

from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)
PLATFORMS: list[Platform] = [Platform.SENSOR]


Expand All @@ -21,6 +24,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
try:
await api.get_current_data()
except BwtException as e:
_LOGGER.exception("Error setting up Bwt API")
await api.close()
raise ConfigEntryNotReady from e

Expand Down
2 changes: 2 additions & 0 deletions custom_components/bwt_perla/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ async def async_step_user(
info = await validate_input(self.hass, user_input)
return self.async_create_entry(title=info["title"], data=user_input)
except ConnectException:
_LOGGER.exception("Connection error setting up the Bwt Api")
errors["base"] = "cannot_connect"
except WrongCodeException:
_LOGGER.exception("Wrong user code passed to bwt api")
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
_LOGGER.exception("Unexpected exception")
Expand Down

0 comments on commit 96a056a

Please sign in to comment.