mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-21 14:38:15 +01:00
test for aiomqtt 2.0 -> NOT WORKING YET
This commit is contained in:
parent
8cab633291
commit
f659eea65b
2 changed files with 7 additions and 9 deletions
|
@ -53,7 +53,7 @@ class SatelliteController:
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.client = Client(self.host, port=self.port, username=self.username, password=self.password, will=Will(topic="cbpi/disconnect", payload="CBPi Server Disconnected"),client_id=self.client_id)
|
self.client = Client(self.host, port=self.port, username=self.username, password=self.password, will=Will(topic="cbpi/disconnect", payload="CBPi Server Disconnected"),identifier=self.client_id)
|
||||||
self.loop = asyncio.get_event_loop()
|
self.loop = asyncio.get_event_loop()
|
||||||
## Listen for mqtt messages in an (unawaited) asyncio task
|
## Listen for mqtt messages in an (unawaited) asyncio task
|
||||||
task = self.loop.create_task(self.listen())
|
task = self.loop.create_task(self.listen())
|
||||||
|
@ -67,9 +67,8 @@ class SatelliteController:
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
async with self.client as client:
|
async with self.client as client:
|
||||||
async with client.messages() as messages:
|
|
||||||
await client.subscribe("#")
|
await client.subscribe("#")
|
||||||
async for message in messages:
|
async for message in client.messages:
|
||||||
for topic_filter in self.topic_filters:
|
for topic_filter in self.topic_filters:
|
||||||
topic = topic_filter[0]
|
topic = topic_filter[0]
|
||||||
method = topic_filter[1]
|
method = topic_filter[1]
|
||||||
|
@ -167,11 +166,10 @@ class SatelliteController:
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
if self.client._connected.done():
|
if self.client._connected.done():
|
||||||
async with self.client.messages() as messages:
|
await self.client.subscribe(topic)
|
||||||
await self.client.subscribe(topic)
|
async for message in self.client.messages:
|
||||||
async for message in messages:
|
if message.topic.matches(topic):
|
||||||
if message.topic.matches(topic):
|
await method(message.payload.decode())
|
||||||
await method(message.payload.decode())
|
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
# Cancel
|
# Cancel
|
||||||
self.logger.warning("Subscription {} Cancelled".format(topic))
|
self.logger.warning("Subscription {} Cancelled".format(topic))
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -56,7 +56,7 @@ setup(name='cbpi4',
|
||||||
'click==8.1.7',
|
'click==8.1.7',
|
||||||
'shortuuid==1.0.11',
|
'shortuuid==1.0.11',
|
||||||
'tabulate==0.9.0',
|
'tabulate==0.9.0',
|
||||||
'aiomqtt==1.2.1',
|
'aiomqtt==2.0.0',
|
||||||
'inquirer==3.1.3',
|
'inquirer==3.1.3',
|
||||||
'colorama==0.4.6',
|
'colorama==0.4.6',
|
||||||
'psutil==5.9.6',
|
'psutil==5.9.6',
|
||||||
|
|
Loading…
Reference in a new issue