mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-09 17:07:43 +01:00
partial update for sattelite controller to adapt to future requirements of asyncio-mqtt
Still some additional work required
This commit is contained in:
parent
4823a04a8e
commit
4dd20ff985
3 changed files with 12 additions and 5 deletions
|
@ -1,3 +1,3 @@
|
||||||
__version__ = "4.1.0.a1"
|
__version__ = "4.1.0.a2"
|
||||||
__codename__ = "November Rain"
|
__codename__ = "Groundhog Day"
|
||||||
|
|
||||||
|
|
|
@ -120,10 +120,11 @@ class SatelliteController:
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
if self.client._connected.done():
|
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)
|
await self.client.subscribe(topic)
|
||||||
async for message in messages:
|
async for message in messages:
|
||||||
await method(message.payload.decode())
|
if message.topic.matches(topic):
|
||||||
|
await method(message.payload.decode())
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
# Cancel
|
# Cancel
|
||||||
self.logger.warning("Sub Cancelled")
|
self.logger.warning("Sub Cancelled")
|
||||||
|
@ -147,7 +148,9 @@ class SatelliteController:
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
pass
|
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:
|
while True:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with AsyncExitStack() as stack:
|
async with AsyncExitStack() as stack:
|
||||||
self.tasks = set()
|
self.tasks = set()
|
||||||
|
@ -158,9 +161,13 @@ class SatelliteController:
|
||||||
|
|
||||||
for topic_filter in self.topic_filters:
|
for topic_filter in self.topic_filters:
|
||||||
topic = topic_filter[0]
|
topic = topic_filter[0]
|
||||||
|
logging.info("Topic: "+topic)
|
||||||
method = topic_filter[1]
|
method = topic_filter[1]
|
||||||
|
logging.info("Method: "+str(method))
|
||||||
manager = self.client.filtered_messages(topic)
|
manager = self.client.filtered_messages(topic)
|
||||||
|
logging.info("Manager: " +str(manager))
|
||||||
messages = await stack.enter_async_context(manager)
|
messages = await stack.enter_async_context(manager)
|
||||||
|
logging.info("Messages: " +str(messages))
|
||||||
task = asyncio.create_task(method(messages))
|
task = asyncio.create_task(method(messages))
|
||||||
self.tasks.add(task)
|
self.tasks.add(task)
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -54,7 +54,7 @@ setup(name='cbpi4',
|
||||||
'click==8.1.3',
|
'click==8.1.3',
|
||||||
'shortuuid==1.0.11',
|
'shortuuid==1.0.11',
|
||||||
'tabulate==0.9.0',
|
'tabulate==0.9.0',
|
||||||
'asyncio-mqtt',
|
'asyncio-mqtt==0.16.1',
|
||||||
'inquirer==3.1.1',
|
'inquirer==3.1.1',
|
||||||
'colorama==0.4.6',
|
'colorama==0.4.6',
|
||||||
'psutil==5.9.4',
|
'psutil==5.9.4',
|
||||||
|
|
Loading…
Reference in a new issue