Skip to content

Commit

Permalink
Merge pull request #449 from MTrab:Do-not-crash-on-Carnot-Outage
Browse files Browse the repository at this point in the history
Do not crash on Carnot outage
  • Loading branch information
MTrab committed Feb 28, 2024
2 parents 8a85193 + 9a02eea commit 571b033
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions custom_components/energidataservice/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from logging import getLogger

import voluptuous as vol
from aiohttp import ServerDisconnectedError
from aiohttp import ClientConnectorError, ServerDisconnectedError
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_API_KEY, CONF_EMAIL
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -194,9 +194,12 @@ async def update_carnot(self, dt=None) -> None: # type: ignore pylint: disable=
)
carnot = forecast_module.Connector(self._region, self._client, self._tz)
self.predictions_currency = forecast_module.DEFAULT_CURRENCY
self.predictions = await carnot.async_get_forecast(
self._carnot_apikey, self._carnot_user
)
try:
self.predictions = await carnot.async_get_forecast(
self._carnot_apikey, self._carnot_user
)
except ClientConnectorError:
_LOGGER.warning("Error fetching data from Carnot")

if not isinstance(self.predictions, type(None)):
self.predictions[:] = (
Expand Down

0 comments on commit 571b033

Please sign in to comment.