api: fix mqtt reconnect logic errors

This commit is contained in:
lilly 2026-05-31 20:53:14 +02:00
commit b752888812
Signed by: lilly
SSH key fingerprint: SHA256:y9T5GFw2A20WVklhetIxG1+kcg/Ce0shnQmbu1LQ37g
2 changed files with 23 additions and 12 deletions

View file

@ -162,15 +162,18 @@ class CCUJackClient:
while True:
try:
await asyncio.sleep(15 * 60) # 15 minutes
logger.info("Running CCUJack cron")
await self.find_locks()
if not self.mqtt.is_connected():
if not self.mqtt.is_connected:
logger.warning("MQTT client was discovered to be disconnected; reconnecting now")
await self.mqtt.connect()
await self.find_locks()
except Exception as e:
logger.exception(f"Error in CCUJack cron task: {e}")
finally:
await asyncio.sleep(15 * 60) # 15 minutes
async def query_param_value(self, address: str) -> CCUValue:
if address in self.param_values: