66from dataclasses import dataclass
77from random import randint
88
9- from .roborock_typing import RoborockCommand
10-
119
1210@dataclass
1311class RoborockMessage :
@@ -20,17 +18,17 @@ class RoborockMessage:
2018
2119 def get_request_id (self ) -> int | None :
2220 protocol = self .protocol
23- if protocol in [4 , 101 , 102 ]:
21+ if self . payload and protocol in [4 , 101 , 102 ]:
2422 payload = json .loads (self .payload .decode ())
2523 for data_point_number , data_point in payload .get ("dps" ).items ():
2624 if data_point_number in ["101" , "102" ]:
2725 data_point_response = json .loads (data_point )
2826 return data_point_response .get ("id" )
2927 return None
3028
31- def get_method (self ) -> RoborockCommand | None :
29+ def get_method (self ) -> str | None :
3230 protocol = self .protocol
33- if protocol in [4 , 5 , 101 , 102 ]:
31+ if self . payload and protocol in [4 , 5 , 101 , 102 ]:
3432 payload = json .loads (self .payload .decode ())
3533 for data_point_number , data_point in payload .get ("dps" ).items ():
3634 if data_point_number in ["101" , "102" ]:
@@ -40,7 +38,7 @@ def get_method(self) -> RoborockCommand | None:
4038
4139 def get_params (self ) -> list | dict | None :
4240 protocol = self .protocol
43- if protocol in [4 , 101 , 102 ]:
41+ if self . payload and protocol in [4 , 101 , 102 ]:
4442 payload = json .loads (self .payload .decode ())
4543 for data_point_number , data_point in payload .get ("dps" ).items ():
4644 if data_point_number in ["101" , "102" ]:
0 commit comments