mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Decrease timeout
and update_interval
in Xiaomi Miio integration (#57339)
* Decrease timeout and update_interval * Improve UPDATE_INTERVAL const * Update values after testing
This commit is contained in:
parent
c76e15149c
commit
276345e20a
@ -73,6 +73,9 @@ from .gateway import ConnectXiaomiGateway
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
POLLING_TIMEOUT_SEC = 10
|
||||
UPDATE_INTERVAL = timedelta(seconds=15)
|
||||
|
||||
GATEWAY_PLATFORMS = ["alarm_control_panel", "light", "sensor", "switch"]
|
||||
SWITCH_PLATFORMS = ["switch"]
|
||||
FAN_PLATFORMS = ["binary_sensor", "fan", "number", "select", "sensor", "switch"]
|
||||
@ -151,7 +154,7 @@ def _async_update_data_default(hass, device):
|
||||
|
||||
async def _async_fetch_data():
|
||||
"""Fetch data from the device."""
|
||||
async with async_timeout.timeout(10):
|
||||
async with async_timeout.timeout(POLLING_TIMEOUT_SEC):
|
||||
state = await hass.async_add_executor_job(device.status)
|
||||
_LOGGER.debug("Got new state: %s", state)
|
||||
return state
|
||||
@ -239,7 +242,7 @@ def _async_update_data_vacuum(hass, device: Vacuum):
|
||||
"""Fetch data from the device using async_add_executor_job."""
|
||||
|
||||
async def execute_update():
|
||||
async with async_timeout.timeout(10):
|
||||
async with async_timeout.timeout(POLLING_TIMEOUT_SEC):
|
||||
state = await hass.async_add_executor_job(update)
|
||||
_LOGGER.debug("Got new vacuum state: %s", state)
|
||||
return state
|
||||
@ -336,7 +339,7 @@ async def async_create_miio_device_and_coordinator(
|
||||
name=name,
|
||||
update_method=update_method(hass, device),
|
||||
# Polling interval. Will only be polled if there are subscribers.
|
||||
update_interval=timedelta(seconds=60),
|
||||
update_interval=UPDATE_INTERVAL,
|
||||
)
|
||||
hass.data[DOMAIN][entry.entry_id] = {
|
||||
KEY_DEVICE: device,
|
||||
@ -409,7 +412,7 @@ async def async_setup_gateway_entry(
|
||||
name=name,
|
||||
update_method=async_update_data,
|
||||
# Polling interval. Will only be polled if there are subscribers.
|
||||
update_interval=timedelta(seconds=10),
|
||||
update_interval=UPDATE_INTERVAL,
|
||||
)
|
||||
|
||||
hass.data[DOMAIN][entry.entry_id] = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user