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 authored and Prior99 committed Sep 21, 2024
1 parent eb3d69e commit 11a0866
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"
COORDINATOR = "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 myskoda.models.user import User
from myskoda.mqtt import EventCharging, EventType

from .const import DOMAIN
from .const import DOMAIN, FETCH_INTERVAL_IN_MINUTES

_LOGGER = logging.getLogger(__name__)

Expand All @@ -22,7 +22,7 @@ class MySkodaDebouncer(Debouncer):

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 @@ -63,8 +63,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 11a0866

Please sign in to comment.