From 78e97428fd7a28dff6d56779a012c1d2a9fdeb87 Mon Sep 17 00:00:00 2001 From: Josef Zweck Date: Sun, 5 Oct 2025 12:31:45 +0200 Subject: [PATCH] Add debouncer to acaia (#153725) --- homeassistant/components/acaia/coordinator.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/acaia/coordinator.py b/homeassistant/components/acaia/coordinator.py index b42cbccaee5..9f29c844235 100644 --- a/homeassistant/components/acaia/coordinator.py +++ b/homeassistant/components/acaia/coordinator.py @@ -12,11 +12,13 @@ from homeassistant.components.bluetooth import async_get_scanner from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_ADDRESS from homeassistant.core import HomeAssistant +from homeassistant.helpers.debounce import Debouncer from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from .const import CONF_IS_NEW_STYLE_SCALE SCAN_INTERVAL = timedelta(seconds=15) +UPDATE_DEBOUNCE_TIME = 0.2 _LOGGER = logging.getLogger(__name__) @@ -38,11 +40,19 @@ class AcaiaCoordinator(DataUpdateCoordinator[None]): config_entry=entry, ) + debouncer = Debouncer( + hass=hass, + logger=_LOGGER, + cooldown=UPDATE_DEBOUNCE_TIME, + immediate=True, + function=self.async_update_listeners, + ) + self._scale = AcaiaScale( address_or_ble_device=entry.data[CONF_ADDRESS], name=entry.title, is_new_style_scale=entry.data[CONF_IS_NEW_STYLE_SCALE], - notify_callback=self.async_update_listeners, + notify_callback=debouncer.async_schedule_call, scanner=async_get_scanner(hass), )