@@ -65,9 +65,9 @@ async def command(self, name, *args) -> Any:
6565 LOGGER .debug ("Send command %s: %s" , name , args )
6666 data = self ._ezsp_frame (name , * args )
6767 self ._gw .data (data )
68- c = self .COMMANDS [name ]
69- future = asyncio .Future ()
70- self ._awaiting [self ._seq ] = (c [ 0 ], c [ 2 ] , future )
68+ cmd_id , _ , rx_schema = self .COMMANDS [name ]
69+ future = asyncio .get_running_loop (). create_future ()
70+ self ._awaiting [self ._seq ] = (cmd_id , rx_schema , future )
7171 self ._seq = (self ._seq + 1 ) % 256
7272
7373 async with asyncio_timeout (EZSP_CMD_TIMEOUT ):
@@ -89,7 +89,7 @@ def __call__(self, data: bytes) -> None:
8989 sequence , frame_id , data = self ._ezsp_frame_rx (data )
9090
9191 try :
92- frame_name , _ , schema = self .COMMANDS_BY_ID [frame_id ]
92+ frame_name , _ , rx_schema = self .COMMANDS_BY_ID [frame_id ]
9393 except KeyError :
9494 LOGGER .warning (
9595 "Unknown application frame 0x%04X received: %s (%s). This is a bug!" ,
@@ -100,7 +100,10 @@ def __call__(self, data: bytes) -> None:
100100 return
101101
102102 try :
103- result , data = self .types .deserialize (data , schema )
103+ if isinstance (rx_schema , tuple ):
104+ result , data = self .types .deserialize (data , rx_schema )
105+ else :
106+ result , data = rx_schema .deserialize (data )
104107 except Exception :
105108 LOGGER .warning (
106109 "Failed to parse frame %s: %s" , frame_name , binascii .hexlify (data )
0 commit comments