Add bmw connected drive region-specific scan interval (#95649)

Add region-specific scan interval

Co-authored-by: rikroe <rikroe@users.noreply.github.com>
This commit is contained in:
Richard Kroegel 2023-07-01 10:41:03 +02:00 committed by GitHub
parent 8b159d0f47
commit 591f1ee338
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -21,3 +21,9 @@ UNIT_MAP = {
"LITERS": UnitOfVolume.LITERS, "LITERS": UnitOfVolume.LITERS,
"GALLONS": UnitOfVolume.GALLONS, "GALLONS": UnitOfVolume.GALLONS,
} }
SCAN_INTERVALS = {
"china": 300,
"north_america": 600,
"rest_of_world": 300,
}

View File

@ -15,10 +15,8 @@ from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed from homeassistant.exceptions import ConfigEntryAuthFailed
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .const import CONF_GCID, CONF_READ_ONLY, CONF_REFRESH_TOKEN, DOMAIN from .const import CONF_GCID, CONF_READ_ONLY, CONF_REFRESH_TOKEN, DOMAIN, SCAN_INTERVALS
DEFAULT_SCAN_INTERVAL_SECONDS = 300
SCAN_INTERVAL = timedelta(seconds=DEFAULT_SCAN_INTERVAL_SECONDS)
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -50,7 +48,7 @@ class BMWDataUpdateCoordinator(DataUpdateCoordinator[None]):
hass, hass,
_LOGGER, _LOGGER,
name=f"{DOMAIN}-{entry.data['username']}", name=f"{DOMAIN}-{entry.data['username']}",
update_interval=SCAN_INTERVAL, update_interval=timedelta(seconds=SCAN_INTERVALS[entry.data[CONF_REGION]]),
) )
async def _async_update_data(self) -> None: async def _async_update_data(self) -> None: