modification on musicmouse host
This commit is contained in:
parent
a67c6078c5
commit
804940bfac
|
@ -145,6 +145,9 @@ class ShelveLightMqtt:
|
|||
|
||||
|
||||
async def start_mqtt(music_mouse_protocol, server, username, password):
|
||||
reconnect_interval = 10 # [seconds]
|
||||
while True:
|
||||
try:
|
||||
async with asyncio_mqtt.Client(hostname=server, username=username, password=password) as client:
|
||||
shelve_light = ShelveLightMqtt(music_mouse_protocol, client)
|
||||
await shelve_light.init()
|
||||
|
@ -152,6 +155,10 @@ async def start_mqtt(music_mouse_protocol, server, username, password):
|
|||
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__":
|
||||
|
|
Loading…
Reference in New Issue