Skip to content

Commit

Permalink
fix: potential disconnect issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cdnninja committed May 26, 2024
1 parent a2a9f76 commit 54b1782
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions yoto_api/YotoMQTTClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ def connect_mqtt(self, token: Token, player: YotoPlayer, callback):
self.client.tls_set()
self.client.connect(host=self.MQTT_URL, port=443)
self.client.loop_start()
self.client.subscribe("device/" + player.id + "/events")
self.client.subscribe("device/" + player.id + "/status")
self.client.subscribe("device/" + player.id + "/response")
# Command not needed but helps sniffing traffic
self.client.subscribe("device/" + player.id + "/command")
self.update_status(player.id)
# time.sleep(60)
# client.loop_stop()

Expand All @@ -51,6 +45,11 @@ def disconnect_mqtt(self):

def _on_connect(self, client, userdata, flags, rc):
_LOGGER.debug(f"{DOMAIN} - {client._client_id} - MQTT connected: {rc}")
player = userdata[0]
self.client.subscribe("device/" + player.id + "/events")
self.client.subscribe("device/" + player.id + "/status")
self.client.subscribe("device/" + player.id + "/response")
self.update_status(player.id)

def _on_disconnect(self, client, userdata, rc):
_LOGGER.debug(f"{DOMAIN} - {client._client_id} - MQTT Disconnected: {rc}")
Expand Down

0 comments on commit 54b1782

Please sign in to comment.