Skip to content

Commit

Permalink
Register the command response listener before sending
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed Feb 9, 2024
1 parent df9c0c6 commit b29cb4f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions zigpy_deconz/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,16 +572,15 @@ async def _command(self, cmd, **kwargs):

async with self._command_lock(priority=self._get_command_priority(command)):
seq = self._seq

LOGGER.debug("Sending %s%s (seq=%s)", cmd, kwargs, seq)
self._uart.send(command.replace(seq=seq).serialize())

self._seq = (self._seq % 255) + 1

fut = asyncio.Future()
self._awaiting[seq][cmd].append(fut)

try:
LOGGER.debug("Sending %s%s (seq=%s)", cmd, kwargs, seq)
self._uart.send(command.replace(seq=seq).serialize())

async with asyncio_timeout(COMMAND_TIMEOUT):
return await fut
except asyncio.TimeoutError:
Expand Down

0 comments on commit b29cb4f

Please sign in to comment.