Adapted to new aiomqtt version
This commit is contained in:
parent
11bf0505fb
commit
b2c060fcc9
|
@ -33,7 +33,7 @@ class ShelveLightMqtt:
|
||||||
await self._notify_mqtt_state({"state": "OFF"})
|
await self._notify_mqtt_state({"state": "OFF"})
|
||||||
|
|
||||||
async def handle_light_message(self, msg):
|
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()
|
payload = msg.payload.decode()
|
||||||
new_state = json.loads(payload)
|
new_state = json.loads(payload)
|
||||||
print("IN ", new_state)
|
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:
|
async with aiomqtt.Client(hostname=server, username=username, password=password) as client:
|
||||||
shelve_light = ShelveLightMqtt(music_mouse_protocol, client)
|
shelve_light = ShelveLightMqtt(music_mouse_protocol, client)
|
||||||
await shelve_light.init()
|
await shelve_light.init()
|
||||||
async with client.filtered_messages("musicmouse_json/#") as messages:
|
await client.subscribe("musicmouse_json/#")
|
||||||
await client.subscribe("musicmouse_json/#")
|
async for message in client.messages:
|
||||||
async for message in messages:
|
await shelve_light.handle_light_message(message)
|
||||||
await shelve_light.handle_light_message(message)
|
|
||||||
except aiomqtt.MqttError as error:
|
except aiomqtt.MqttError as error:
|
||||||
print(f'Error "{error}". Reconnecting in {reconnect_interval} seconds')
|
print(f'Error "{error}". Reconnecting in {reconnect_interval} seconds')
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Reference in New Issue