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

This commit is contained in:
Erik Montnemery authored and GitHub committed 2020-04-22 14:38:04 -07:00
1 parent d6ab36bf8e
commit 4448eb94a1
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: