From 8d2315df8ebc78192dfa0b143483c7e44cfc6260 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Fri, 16 Feb 2024 13:17:23 -0500 Subject: [PATCH] Register the command response listener before sending (#248) --- zigpy_deconz/api.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/zigpy_deconz/api.py b/zigpy_deconz/api.py index f8463c1..e91991a 100644 --- a/zigpy_deconz/api.py +++ b/zigpy_deconz/api.py @@ -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: