diff --git a/custom_components/myskoda/const.py b/custom_components/myskoda/const.py index 9af550d..ab727ff 100644 --- a/custom_components/myskoda/const.py +++ b/custom_components/myskoda/const.py @@ -2,3 +2,6 @@ DOMAIN = "myskoda" DATA_COODINATOR = "coordinator" + +FETCH_INTERVAL_IN_MINUTES = 30 +API_COOLDOWN_IN_SECONDS = 60.0 diff --git a/custom_components/myskoda/coordinator.py b/custom_components/myskoda/coordinator.py index caa13fa..d3bcee9 100644 --- a/custom_components/myskoda/coordinator.py +++ b/custom_components/myskoda/coordinator.py @@ -12,7 +12,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.util.ssl import get_default_context from myskoda.mqtt import EventCharging, EventType -from .const import DOMAIN +from .const import DOMAIN, FETCH_INTERVAL_IN_MINUTES from typing import Any _LOGGER = logging.getLogger(__name__) @@ -23,7 +23,7 @@ class MySkodaDebouncer(Debouncer[Coroutine[Any, Any, None]]): def __init__(self, hass: HomeAssistant) -> None: """Initialize debounce.""" - super.__init__(hass, _LOGGER, cooldown=60.0, immediate=False) + super.__init__(hass, _LOGGER, cooldown=API_COOLDOWN_IN_SECONDS, immediate=False) async def async_call(self) -> None: """Call the intended function.""" @@ -64,8 +64,9 @@ def __init__(self, hass: HomeAssistant, config: ConfigEntry) -> None: hass, _LOGGER, name=DOMAIN, - update_interval=timedelta(minutes=30), + update_interval=timedelta(minutes=FETCH_INTERVAL_IN_MINUTES), request_refresh_debouncer=MySkodaDebouncer(hass), + always_update=False ) self.myskoda = MySkoda(async_get_clientsession(hass)) self.config = config