Reduce coordinator cooldown for roku (#65973)

This commit is contained in:
Chris Talkington 2022-02-07 02:03:19 -06:00 committed by GitHub
parent 211db79f11
commit 18ac72f613
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,11 +9,14 @@ from rokuecp.models import Device
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.debounce import Debouncer
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from homeassistant.util.dt import utcnow
from .const import DOMAIN
REQUEST_REFRESH_DELAY = 0.35
SCAN_INTERVAL = timedelta(seconds=10)
_LOGGER = logging.getLogger(__name__)
@ -41,6 +44,11 @@ class RokuDataUpdateCoordinator(DataUpdateCoordinator[Device]):
_LOGGER,
name=DOMAIN,
update_interval=SCAN_INTERVAL,
# We don't want an immediate refresh since the device
# takes a moment to reflect the state change
request_refresh_debouncer=Debouncer(
hass, _LOGGER, cooldown=REQUEST_REFRESH_DELAY, immediate=False
),
)
async def _async_update_data(self) -> Device: