@@ -229,23 +229,17 @@ def mqtt_publish(self, topic: str, payload: Any = None, **kwargs: Optional[Any])
229229 result = self .call_service (service , ** kwargs )
230230 return result
231231
232- def _run_service_call (self , task : str , topic : Union [ str , list ], ** kwargs : Optional [Any ]) -> None :
232+ def _run_service_call (self , task : str , topic : str | list [ str ], ** kwargs : Optional [Any ]) -> None :
233233 """Used to process the subscribe/unsubscribe service calls"""
234234
235235 # first we validate the topic
236236 if not isinstance (topic , (str , list )):
237237 raise ValueError (f"The given topic { topic } is not supported. Please only strs and lists are supported" )
238238
239- if isinstance (topic , str ):
240- kwargs ["topic" ] = topic
241- service = f"mqtt/{ task } "
242- self .call_service (service , ** kwargs )
239+ kwargs ["topic" ] = topic
240+ service = f"mqtt/{ task } "
241+ return self .call_service (service , ** kwargs )
243242
244- else : # its a list
245- for t in topic :
246- kwargs ["topic" ] = t
247- service = f"mqtt/{ task } "
248- self .call_service (service , ** kwargs )
249243
250244 def mqtt_subscribe (self , topic : Union [str , list ], ** kwargs : Optional [Any ]) -> None :
251245 """Subscribes to a MQTT topic.
@@ -284,7 +278,7 @@ def mqtt_subscribe(self, topic: Union[str, list], **kwargs: Optional[Any]) -> No
284278
285279 """
286280
287- self ._run_service_call ("subscribe" , topic , ** kwargs )
281+ return self ._run_service_call ("subscribe" , topic , ** kwargs )
288282
289283 def mqtt_unsubscribe (self , topic : Union [str , list ], ** kwargs : Optional [Any ]) -> None :
290284 """Unsubscribes from a MQTT topic.
@@ -323,7 +317,7 @@ def mqtt_unsubscribe(self, topic: Union[str, list], **kwargs: Optional[Any]) ->
323317
324318 """
325319
326- self ._run_service_call ("unsubscribe" , topic , ** kwargs )
320+ return self ._run_service_call ("unsubscribe" , topic , ** kwargs )
327321
328322 @utils .sync_decorator
329323 async def is_client_connected (self , ** kwargs : Optional [Any ]) -> bool :
0 commit comments