Add asyncio locks to screenlogic api access points (#48457)

This commit is contained in:
Kevin Worrel 2021-03-29 16:27:17 -07:00 committed by GitHub
parent c1d5638739
commit 42a060ad33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 15 deletions

View file

@ -44,9 +44,12 @@ class ScreenLogicSwitch(ScreenlogicEntity, SwitchEntity):
return await self._async_set_circuit(ON_OFF.OFF)
async def _async_set_circuit(self, circuit_value) -> None:
if await self.hass.async_add_executor_job(
self.gateway.set_circuit, self._data_key, circuit_value
):
async with self.coordinator.api_lock:
success = await self.hass.async_add_executor_job(
self.gateway.set_circuit, self._data_key, circuit_value
)
if success:
_LOGGER.debug("Turn %s %s", self._data_key, circuit_value)
await self.coordinator.async_request_refresh()
else: