Only subscribe when MQTT client is connected. (#34557)

This commit is contained in:
Erik Montnemery authored and Paulus Schoutsen committed 2020-04-23 12:57:53 -07:00
1 parent 38342b2f25
commit 3560081efd
2 files changed
+15 -1

No files matched your search

+3 -1
View File
@@ -872,7 +872,9 @@ class MQTT:
subscription = Subscription(topic, msg_callback, qos, encoding)
self.subscriptions.append(subscription)
await self._async_perform_subscription(topic, qos)
# Only subscribe if currently connected.
if self.connected:
await self._async_perform_subscription(topic, qos)
@callback
def async_remove() -> None: