Skip to content

Commit

Permalink
migrate to ~=2.0.0 for aiomqtt
Browse files Browse the repository at this point in the history
  • Loading branch information
mralext20 committed Apr 20, 2024
1 parent 4929910 commit 462de3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
21 changes: 10 additions & 11 deletions alexBot/cogs/mqttDispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@ async def mqttLoop(self):
hostname=url.hostname, username=url.username, password=url.password, port=url.port
) as client:
self.active_client = client
async with client.messages() as messages:
await client.subscribe("alex-bot/#")
async for message in messages:
if message.topic.matches("alex-bot/location/#"):
self.bot.dispatch(
"ha_update_location", message.topic.value.split('/')[2], message.payload.decode()
)
if message.topic.matches("alex-bot/vcControl/#"):
self.bot.dispatch(
"ha_vc_control", message.topic.value.split('/')[2], message.payload.decode()
)
await client.subscribe("alex-bot/#")
async for message in client.messages:
if message.topic.matches("alex-bot/location/#"):
self.bot.dispatch(
"ha_update_location", message.topic.value.split('/')[2], message.payload.decode()
)
if message.topic.matches("alex-bot/vcControl/#"):
self.bot.dispatch(
"ha_vc_control", message.topic.value.split('/')[2], message.payload.decode()
)

except aiomqtt.MqttError as error:
log.error(f"MQTT error: {error}, retrying in 5 minutes")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ yt-dlp
emoji-data
httpx
feedparser
aiomqtt
aiomqtt~=2.0.0
async-gTTS
SQLAlchemy~=2.0.0
alembic
Expand Down

0 comments on commit 462de3d

Please sign in to comment.