From b2c060fcc98063cf4c33ffe37c52ea7f165d4c9b Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Thu, 7 Mar 2024 16:38:05 +0100 Subject: [PATCH] Adapted to new aiomqtt version --- espmusicmouse/host_driver/mqtt_json.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/espmusicmouse/host_driver/mqtt_json.py b/espmusicmouse/host_driver/mqtt_json.py index 1085a7e..1d2658a 100644 --- a/espmusicmouse/host_driver/mqtt_json.py +++ b/espmusicmouse/host_driver/mqtt_json.py @@ -33,7 +33,7 @@ class ShelveLightMqtt: await self._notify_mqtt_state({"state": "OFF"}) async def handle_light_message(self, msg): - if msg.topic == self._discovery_spec['command_topic']: + if msg.topic.value == self._discovery_spec['command_topic']: payload = msg.payload.decode() new_state = json.loads(payload) print("IN ", new_state) @@ -179,10 +179,9 @@ async def start_mqtt(music_mouse_protocol, server, username, password): async with aiomqtt.Client(hostname=server, username=username, password=password) as client: shelve_light = ShelveLightMqtt(music_mouse_protocol, client) await shelve_light.init() - async with client.filtered_messages("musicmouse_json/#") as messages: - await client.subscribe("musicmouse_json/#") - async for message in messages: - await shelve_light.handle_light_message(message) + await client.subscribe("musicmouse_json/#") + async for message in client.messages: + await shelve_light.handle_light_message(message) except aiomqtt.MqttError as error: print(f'Error "{error}". Reconnecting in {reconnect_interval} seconds') finally: