From f525edaa31491db0bc40dfe41d34e9d508764c9c Mon Sep 17 00:00:00 2001 From: CyrilP Date: Tue, 23 Mar 2021 18:43:34 +0100 Subject: [PATCH] refresh all data when homeassistant starts --- mqtt_client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mqtt_client.py b/mqtt_client.py index 06728e4..c10bf05 100644 --- a/mqtt_client.py +++ b/mqtt_client.py @@ -69,7 +69,7 @@ def on_connect(self, client, flags, rc, properties): print("##################################") try: print("Subscribing to : ", tydom_topic) - # client.subscribe('homeassistant/#', qos=0) + client.subscribe('homeassistant/status', qos=0) client.subscribe(tydom_topic, qos=0) except Exception as e: print("Error on connect : ", e) @@ -92,7 +92,8 @@ async def on_message(self, client, topic, payload, qos, properties): elif (topic == "homeassistant/requests/tydom/scenarii"): print('Incoming MQTT scenarii request : ', topic, payload) await self.tydom.get_scenarii() - + elif (topic == "homeassistant/status" and payload.decode() == 'online'): + await self.tydom.get_devices_data() elif (topic == "/tydom/init"): print('Incoming MQTT init request : ', topic, payload) await self.tydom.connect()