Add an asyncio Lock around pairing, which cant be used concurrently (#21933)

This commit is contained in:
Jc2k 2019-03-11 18:59:41 +00:00 committed by Paulus Schoutsen
parent 4f5446ff02
commit 5e2302e469
7 changed files with 76 additions and 63 deletions

View file

@ -48,20 +48,20 @@ class HomeKitSwitch(HomeKitEntity, SwitchDevice):
"""Return true if device is on."""
return self._on
def turn_on(self, **kwargs):
async def async_turn_on(self, **kwargs):
"""Turn the specified switch on."""
self._on = True
characteristics = [{'aid': self._aid,
'iid': self._chars['on'],
'value': True}]
self.put_characteristics(characteristics)
await self._accessory.put_characteristics(characteristics)
def turn_off(self, **kwargs):
async def async_turn_off(self, **kwargs):
"""Turn the specified switch off."""
characteristics = [{'aid': self._aid,
'iid': self._chars['on'],
'value': False}]
self.put_characteristics(characteristics)
await self._accessory.put_characteristics(characteristics)
@property
def device_state_attributes(self):