Skip to content

Commit

Permalink
Catch charger not found error
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberjunky committed Aug 12, 2024
1 parent 1bf2b93 commit 4662e89
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions custom_components/shell_recharge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from asyncio.exceptions import CancelledError

import shellrecharge
from shellrecharge import LocationEmptyError

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -70,6 +72,11 @@ async def _async_update_data(self) -> shellrecharge.Location | None:
data = None
try:
data = await self.api.location_by_id(self.serial_number)
except LocationEmptyError:
_LOGGER.error(
"Error occurred while fetching data for charger(s) %s, not found, or serial is invalid",
self.serial_number,
)
except CancelledError:
_LOGGER.error(
"CancelledError occurred while fetching data for charger(s) %s",
Expand Down

0 comments on commit 4662e89

Please sign in to comment.