@@ -56,19 +56,19 @@ def on_connect(self, *args, **kwargs):
5656 _ , __ , ___ , rc , ____ = args
5757 connection_queue = self ._waiting_queue .get (CONNECT_REQUEST_ID )
5858 if rc != mqtt .MQTT_ERR_SUCCESS :
59- message = f"Failed to connect (rc: { rc } )"
59+ message = f"Failed to connect ({ mqtt . error_string ( rc ) } )"
6060 _LOGGER .error (message )
6161 if connection_queue :
62- connection_queue .resolve ((None , VacuumError (rc , message )))
62+ connection_queue .resolve ((None , VacuumError (message )))
6363 return
6464 _LOGGER .info (f"Connected to mqtt { self ._mqtt_host } :{ self ._mqtt_port } " )
6565 topic = f"rr/m/o/{ self ._mqtt_user } /{ self ._hashed_user } /{ self .device_info .device .duid } "
6666 (result , mid ) = self .subscribe (topic )
6767 if result != 0 :
68- message = f"Failed to subscribe (rc: { result } )"
68+ message = f"Failed to subscribe ({ mqtt . error_string ( rc ) } )"
6969 _LOGGER .error (message )
7070 if connection_queue :
71- connection_queue .resolve ((None , VacuumError (rc , message )))
71+ connection_queue .resolve ((None , VacuumError (message )))
7272 return
7373 _LOGGER .info (f"Subscribed to topic { topic } " )
7474 if connection_queue :
@@ -85,7 +85,7 @@ def on_message(self, *args, **kwargs):
8585 def on_disconnect (self , * args , ** kwargs ):
8686 _ , __ , rc , ___ = args
8787 try :
88- super ().on_connection_lost (RoborockException (f" (rc: { rc } )" ))
88+ super ().on_connection_lost (RoborockException (mqtt . error_string (rc ) ))
8989 if rc == mqtt .MQTT_ERR_PROTOCOL :
9090 self .update_client_id ()
9191 connection_queue = self ._waiting_queue .get (DISCONNECT_REQUEST_ID )
@@ -114,7 +114,7 @@ def sync_disconnect(self) -> bool:
114114 _LOGGER .info ("Disconnecting from mqtt" )
115115 rc = super ().disconnect ()
116116 if rc not in [mqtt .MQTT_ERR_SUCCESS , mqtt .MQTT_ERR_NO_CONN ]:
117- raise RoborockException (f"Failed to disconnect (rc: { rc } )" )
117+ raise RoborockException (f"Failed to disconnect ({ mqtt . error_string ( rc ) } )" )
118118 return rc == mqtt .MQTT_ERR_SUCCESS
119119
120120 def sync_connect (self ) -> bool :
@@ -146,7 +146,7 @@ async def async_connect(self) -> None:
146146 def _send_msg_raw (self , msg : bytes ) -> None :
147147 info = self .publish (f"rr/m/i/{ self ._mqtt_user } /{ self ._hashed_user } /{ self .device_info .device .duid } " , msg )
148148 if info .rc != mqtt .MQTT_ERR_SUCCESS :
149- raise RoborockException (f"Failed to publish (rc: { info .rc } )" )
149+ raise RoborockException (f"Failed to publish ({ mqtt . error_string ( info .rc ) } )" )
150150
151151 async def send_command (self , method : RoborockCommand , params : Optional [list | dict ] = None ):
152152 await self .validate_connection ()
0 commit comments