Add an asyncio Lock around pairing, which cant be used concurrently (#21933)
This commit is contained in:
parent
4f5446ff02
commit
5e2302e469
7 changed files with 76 additions and 63 deletions
|
@ -114,20 +114,20 @@ class HomeKitGarageDoorCover(HomeKitEntity, CoverDevice):
|
|||
"""Return if the cover is opening or not."""
|
||||
return self._state == STATE_OPENING
|
||||
|
||||
def open_cover(self, **kwargs):
|
||||
async def async_open_cover(self, **kwargs):
|
||||
"""Send open command."""
|
||||
self.set_door_state(STATE_OPEN)
|
||||
await self.set_door_state(STATE_OPEN)
|
||||
|
||||
def close_cover(self, **kwargs):
|
||||
async def async_close_cover(self, **kwargs):
|
||||
"""Send close command."""
|
||||
self.set_door_state(STATE_CLOSED)
|
||||
await self.set_door_state(STATE_CLOSED)
|
||||
|
||||
def set_door_state(self, state):
|
||||
async def set_door_state(self, state):
|
||||
"""Send state command."""
|
||||
characteristics = [{'aid': self._aid,
|
||||
'iid': self._chars['door-state.target'],
|
||||
'value': TARGET_GARAGE_STATE_MAP[state]}]
|
||||
self.put_characteristics(characteristics)
|
||||
await self._accessory.put_characteristics(characteristics)
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
@ -232,41 +232,41 @@ class HomeKitWindowCover(HomeKitEntity, CoverDevice):
|
|||
"""Return if the cover is opening or not."""
|
||||
return self._state == STATE_OPENING
|
||||
|
||||
def open_cover(self, **kwargs):
|
||||
async def async_open_cover(self, **kwargs):
|
||||
"""Send open command."""
|
||||
self.set_cover_position(position=100)
|
||||
await self.async_set_cover_position(position=100)
|
||||
|
||||
def close_cover(self, **kwargs):
|
||||
async def close_cover(self, **kwargs):
|
||||
"""Send close command."""
|
||||
self.set_cover_position(position=0)
|
||||
await self.async_set_cover_position(position=0)
|
||||
|
||||
def set_cover_position(self, **kwargs):
|
||||
async def async_set_cover_position(self, **kwargs):
|
||||
"""Send position command."""
|
||||
position = kwargs[ATTR_POSITION]
|
||||
characteristics = [{'aid': self._aid,
|
||||
'iid': self._chars['position.target'],
|
||||
'value': position}]
|
||||
self.put_characteristics(characteristics)
|
||||
await self._accessory.put_characteristics(characteristics)
|
||||
|
||||
@property
|
||||
def current_cover_tilt_position(self):
|
||||
"""Return current position of cover tilt."""
|
||||
return self._tilt_position
|
||||
|
||||
def set_cover_tilt_position(self, **kwargs):
|
||||
async def async_set_cover_tilt_position(self, **kwargs):
|
||||
"""Move the cover tilt to a specific position."""
|
||||
tilt_position = kwargs[ATTR_TILT_POSITION]
|
||||
if 'vertical-tilt.target' in self._chars:
|
||||
characteristics = [{'aid': self._aid,
|
||||
'iid': self._chars['vertical-tilt.target'],
|
||||
'value': tilt_position}]
|
||||
self.put_characteristics(characteristics)
|
||||
await self._accessory.put_characteristics(characteristics)
|
||||
elif 'horizontal-tilt.target' in self._chars:
|
||||
characteristics = [{'aid': self._aid,
|
||||
'iid':
|
||||
self._chars['horizontal-tilt.target'],
|
||||
'value': tilt_position}]
|
||||
self.put_characteristics(characteristics)
|
||||
await self._accessory.put_characteristics(characteristics)
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue