Skip to content

Commit

Permalink
Add updatefailed and increase update_interval
Browse files Browse the repository at this point in the history
  • Loading branch information
klaasnicolaas committed Sep 12, 2021
1 parent 16f4905 commit 0b69e20
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions custom_components/omnik_inverter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from omnikinverter.exceptions import OmnikInverterError

from .const import (
CONF_USE_JSON,
Expand Down Expand Up @@ -90,9 +91,11 @@ def __init__(

async def _async_update_data(self) -> OmnikInverterData:
"""Fetch data from Omnik Inverter."""
data: OmnikInverterData = {
SERVICE_INVERTER: await self.omnikinverter.inverter(),
SERVICE_DEVICE: await self.omnikinverter.device(),
}

return data
try:
data: OmnikInverterData = {
SERVICE_INVERTER: await self.omnikinverter.inverter(),
SERVICE_DEVICE: await self.omnikinverter.device(),
}
return data
except OmnikInverterError as err:
raise UpdateFailed(err) from err
2 changes: 1 addition & 1 deletion custom_components/omnik_inverter/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

DOMAIN: Final = "omnik_inverter"
LOGGER = logging.getLogger(__package__)
SCAN_INTERVAL = timedelta(minutes=1)
SCAN_INTERVAL = timedelta(minutes=4)

CONF_USE_JSON = "use json"

Expand Down

0 comments on commit 0b69e20

Please sign in to comment.