Skip to content

Commit

Permalink
Move some hardcoded values to constants
Browse files Browse the repository at this point in the history
  • Loading branch information
WebSpider committed Sep 20, 2024
1 parent 200633f commit 3902bbb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions custom_components/myskoda/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

DOMAIN = "myskoda"
DATA_COODINATOR = "coordinator"

FETCH_INTERVAL_IN_MINUTES = 30
API_COOLDOWN_IN_SECONDS = 60.0
7 changes: 4 additions & 3 deletions custom_components/myskoda/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand All @@ -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."""
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3902bbb

Please sign in to comment.