Skip to content

Commit

Permalink
Register the command response listener before sending (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly authored Feb 16, 2024
1 parent 8c64072 commit 8d2315d
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 @@ -576,16 +576,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 8d2315d

Please sign in to comment.