api: automatically rediscover locks from CCUJack
All checks were successful
Build Container / Build Container (push) Successful in 1m35s

closes CCCHH/dooris#5
This commit is contained in:
lilly 2026-05-19 15:03:26 +02:00
commit 2349e58924
Signed by: lilly
SSH key fingerprint: SHA256:y9T5GFw2A20WVklhetIxG1+kcg/Ce0shnQmbu1LQ37g
3 changed files with 24 additions and 5 deletions

View file

@ -3,7 +3,7 @@
# https://github.com/eclipse-paho/paho.mqtt.python/blob/master/examples/loop_asyncio.py
#
from typing import Any, List, Set, Iterable
from typing import Any, Set, Iterable
import logging
import asyncio
import socket
@ -132,6 +132,7 @@ class AsyncMqttClient:
self.fut_subscribe = asyncio.get_running_loop().create_future()
self.client.subscribe([(i, qos) for i in to_add])
await self.fut_subscribe
self.active_subscriptions.update(to_add)
to_remove = self.active_subscriptions.difference(topics)
if to_remove:
@ -139,6 +140,7 @@ class AsyncMqttClient:
self.fut_unsubscribe = asyncio.get_running_loop().create_future()
self.client.unsubscribe(list(to_remove))
await self.fut_unsubscribe
self.active_subscriptions.difference_update(to_remove)
async def connect(self):
server_host, server_port = self.connection_string.rsplit(":", maxsplit=1)