Add 1.5 second sleep to motion blinds update (#75494)

This commit is contained in:
starkillerOG 2022-07-27 00:01:49 +02:00 committed by GitHub
parent fb52f5098f
commit 6868865e3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,36 +65,43 @@ class DataUpdateCoordinatorMotionBlinds(DataUpdateCoordinator):
self._wait_for_push = coordinator_info[CONF_WAIT_FOR_PUSH]
def update_gateway(self):
"""Call all updates using one async_add_executor_job."""
data = {}
"""Fetch data from gateway."""
try:
self._gateway.Update()
except (timeout, ParseException):
# let the error be logged and handled by the motionblinds library
data[KEY_GATEWAY] = {ATTR_AVAILABLE: False}
return data
return {ATTR_AVAILABLE: False}
else:
data[KEY_GATEWAY] = {ATTR_AVAILABLE: True}
return {ATTR_AVAILABLE: True}
for blind in self._gateway.device_list.values():
try:
if self._wait_for_push:
blind.Update()
else:
blind.Update_trigger()
except (timeout, ParseException):
# let the error be logged and handled by the motionblinds library
data[blind.mac] = {ATTR_AVAILABLE: False}
def update_blind(self, blind):
"""Fetch data from a blind."""
try:
if self._wait_for_push:
blind.Update()
else:
data[blind.mac] = {ATTR_AVAILABLE: True}
return data
blind.Update_trigger()
except (timeout, ParseException):
# let the error be logged and handled by the motionblinds library
return {ATTR_AVAILABLE: False}
else:
return {ATTR_AVAILABLE: True}
async def _async_update_data(self):
"""Fetch the latest data from the gateway and blinds."""
data = {}
async with self.api_lock:
data = await self.hass.async_add_executor_job(self.update_gateway)
data[KEY_GATEWAY] = await self.hass.async_add_executor_job(
self.update_gateway
)
for blind in self._gateway.device_list.values():
await asyncio.sleep(1.5)
async with self.api_lock:
data[blind.mac] = await self.hass.async_add_executor_job(
self.update_blind, blind
)
all_available = all(device[ATTR_AVAILABLE] for device in data.values())
if all_available: