Don't set connected until rc code is checked

This commit is contained in:
Nick Mowen 2022-11-19 10:18:37 -07:00
parent 5a59426c64
commit 3f2dc8dceb

View File

@ -285,7 +285,6 @@ class FrigateMqttClient:
def _on_connect(self, client: mqtt.Client, userdata, flags, rc) -> None: def _on_connect(self, client: mqtt.Client, userdata, flags, rc) -> None:
"""Mqtt connection callback.""" """Mqtt connection callback."""
self.connected = True
threading.current_thread().name = "mqtt" threading.current_thread().name = "mqtt"
if rc != 0: if rc != 0:
if rc == 3: if rc == 3:
@ -304,6 +303,7 @@ class FrigateMqttClient:
+ str(rc) + str(rc)
) )
self.connected = True
logger.debug("MQTT connected") logger.debug("MQTT connected")
client.subscribe(f"{self.mqtt_config.topic_prefix}/#") client.subscribe(f"{self.mqtt_config.topic_prefix}/#")
self._set_initial_topics() self._set_initial_topics()