modification on musicmouse host
This commit is contained in:
parent
a67c6078c5
commit
804940bfac
|
@ -145,13 +145,20 @@ class ShelveLightMqtt:
|
||||||
|
|
||||||
|
|
||||||
async def start_mqtt(music_mouse_protocol, server, username, password):
|
async def start_mqtt(music_mouse_protocol, server, username, password):
|
||||||
async with asyncio_mqtt.Client(hostname=server, username=username, password=password) as client:
|
reconnect_interval = 10 # [seconds]
|
||||||
shelve_light = ShelveLightMqtt(music_mouse_protocol, client)
|
while True:
|
||||||
await shelve_light.init()
|
try:
|
||||||
async with client.filtered_messages("musicmouse_json/#") as messages:
|
async with asyncio_mqtt.Client(hostname=server, username=username, password=password) as client:
|
||||||
await client.subscribe("musicmouse_json/#")
|
shelve_light = ShelveLightMqtt(music_mouse_protocol, client)
|
||||||
async for message in messages:
|
await shelve_light.init()
|
||||||
await shelve_light.handle_light_message(message)
|
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)
|
||||||
|
except MqttError as error:
|
||||||
|
print(f'Error "{error}". Reconnecting in {reconnect_interval} seconds')
|
||||||
|
finally:
|
||||||
|
await asyncio.sleep(reconnect_interval)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue