Skip to content

Commit

Permalink
Run client.subscribe from within connect callback, so that it gets re…
Browse files Browse the repository at this point in the history
…-run in case we have disconnects/reconnects
  • Loading branch information
optiluca authored and gicamm committed Nov 5, 2024
1 parent 45d7aba commit fab0149
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/comelit/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def on_message_callback(client, userdata, message):

def connect_callback(client, userdata, flags, rc):
try:
_LOGGER.info("connected to comelit hub")
client.subscribe(client.hub.topic_tx)
client.hub.announce()
except Exception as e:
_LOGGER.exception(e)
Expand Down Expand Up @@ -224,12 +224,12 @@ def __init__(self, client_name, hub_serial, hub_host, mqtt_port, mqtt_user, mqtt
self.client.on_disconnect = disconnect_callback
self.client.username_pw_set(mqtt_user, mqtt_password)
self.client.connect(hub_host, mqtt_port, 45)
self.client.subscribe(self.topic_tx)
self.status_thread = StatusUpdater("Thread#1", self._scan_interval, self)

def start(self):
self.status_thread.start()

self.client.loop_start()
self.status_thread.start()

def dispatch(self, payload):
try:
Expand Down

0 comments on commit fab0149

Please # to comment.