diff --git a/bluetti_mqtt/mqtt_client.py b/bluetti_mqtt/mqtt_client.py index dd62c4c..fb11985 100644 --- a/bluetti_mqtt/mqtt_client.py +++ b/bluetti_mqtt/mqtt_client.py @@ -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 @@ -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: @@ -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 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index caac230..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -asyncio-mqtt==0.12.1 -bleak==0.14.3 -crcmod==1.7 -dbus-next==0.2.3 -paho-mqtt==1.6.1 diff --git a/setup.cfg b/setup.cfg index e3612b4..9827d20 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,7 +18,7 @@ python_requires = >=3.7 packages = find: zip_safe = false install_requires = - asyncio-mqtt + aiomqtt bleak crcmod