partial update for sattelite controller to adapt to future requirements of asyncio-mqtt

Still some additional work required
This commit is contained in:
avollkopf 2023-01-08 12:05:17 +01:00
parent 4823a04a8e
commit 4dd20ff985
3 changed files with 12 additions and 5 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.1.0.a1"
__codename__ = "November Rain"
__version__ = "4.1.0.a2"
__codename__ = "Groundhog Day"

View file

@ -120,9 +120,10 @@ class SatelliteController:
while True:
try:
if self.client._connected.done():
async with self.client.filtered_messages(topic) as messages:
async with self.client.messages() as messages:
await self.client.subscribe(topic)
async for message in messages:
if message.topic.matches(topic):
await method(message.payload.decode())
except asyncio.CancelledError:
# Cancel
@ -147,7 +148,9 @@ class SatelliteController:
except asyncio.CancelledError:
pass
# This part needs to be updated in future as filtered_messages() is depracted and will be removed in future from asyncio-mqtt
while True:
try:
async with AsyncExitStack() as stack:
self.tasks = set()
@ -158,9 +161,13 @@ class SatelliteController:
for topic_filter in self.topic_filters:
topic = topic_filter[0]
logging.info("Topic: "+topic)
method = topic_filter[1]
logging.info("Method: "+str(method))
manager = self.client.filtered_messages(topic)
logging.info("Manager: " +str(manager))
messages = await stack.enter_async_context(manager)
logging.info("Messages: " +str(messages))
task = asyncio.create_task(method(messages))
self.tasks.add(task)

View file

@ -54,7 +54,7 @@ setup(name='cbpi4',
'click==8.1.3',
'shortuuid==1.0.11',
'tabulate==0.9.0',
'asyncio-mqtt',
'asyncio-mqtt==0.16.1',
'inquirer==3.1.1',
'colorama==0.4.6',
'psutil==5.9.4',