Skip to content

Commit f3f7ea5

Browse files
committed
Change prusalink update cooldown to 0.5 seconds
While the standard update rate of this intgration is 30 seconds, it's possible to use homeassistant.update_entity to poll more frequently, see https://www.home-assistant.io/common-tasks/general/#why-use-an-automation-instead-of-changing-the-integrations-polling-configuration. But this method is limited by the update coordinator default cooldown, 10 seconds, which is too long to collect rapidly-changing metrics like temperature. This change will allow homeassistant.update_entity to update up to twice per second, which should be fast enough while still providing some protection against polling the printer too fast.
1 parent af951ff commit f3f7ea5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

homeassistant/components/prusalink/coordinator.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@
2121

2222
from homeassistant.config_entries import ConfigEntry
2323
from homeassistant.core import HomeAssistant, callback
24+
from homeassistant.helpers.debounce import Debouncer
2425
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
2526

2627
from .const import DOMAIN
2728

2829
_LOGGER = logging.getLogger(__name__)
2930

31+
# Allow automations using homeassistant.update_entity to collect
32+
# rapidly-changing metrics.
33+
_MINIMUM_REFRESH_INTERVAL = 0.5
3034

3135
T = TypeVar("T", PrinterStatus, LegacyPrinterStatus, JobInfo)
3236

@@ -49,6 +53,9 @@ def __init__(
4953
config_entry=config_entry,
5054
name=DOMAIN,
5155
update_interval=self._get_update_interval(None),
56+
request_refresh_debouncer=Debouncer(
57+
hass, _LOGGER, cooldown=_MINIMUM_REFRESH_INTERVAL, immediate=True
58+
),
5259
)
5360

5461
async def _async_update_data(self) -> T:

0 commit comments

Comments
 (0)