Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency for aiomqtt from asyncio-mqtt #108

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions bluetti_mqtt/mqtt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
import re
from typing import List, Optional
from asyncio_mqtt import Client, MqttError
from aiomqtt import Client, MqttError
from paho.mqtt.client import MQTTMessage
from bluetti_mqtt.bus import CommandMessage, EventBus, ParserMessage
from bluetti_mqtt.core import BluettiDevice, DeviceCommand
Expand Down Expand Up @@ -535,10 +535,9 @@ async def handle_message(self, msg: ParserMessage):
await self.message_queue.put(msg)

async def _handle_commands(self, client: Client):
async with client.filtered_messages('bluetti/command/#') as messages:
await client.subscribe('bluetti/command/#')
async for mqtt_message in messages:
await self._handle_command(mqtt_message)
await client.subscribe('bluetti/command/#')
async for mqtt_message in client.messages:
await self._handle_command(mqtt_message)

async def _handle_messages(self, client: Client):
while True:
Expand Down Expand Up @@ -632,7 +631,7 @@ def payload(id: str, device: BluettiDevice, field: MqttFieldConfig) -> str:

async def _handle_command(self, mqtt_message: MQTTMessage):
# Parse the mqtt_message.topic
m = COMMAND_TOPIC_RE.match(mqtt_message.topic)
m = COMMAND_TOPIC_RE.match(str(mqtt_message.topic))
if not m:
logging.warn(f'unknown command topic: {mqtt_message.topic}')
return
Expand Down
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ python_requires = >=3.7
packages = find:
zip_safe = false
install_requires =
asyncio-mqtt
aiomqtt
bleak
crcmod

Expand Down