mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-10 01:17:42 +01:00
add unique client id for mqtt broker
This commit is contained in:
parent
7f76645b05
commit
2d5ca55718
2 changed files with 4 additions and 2 deletions
|
@ -1,3 +1,3 @@
|
||||||
__version__ = "4.1.0.a4"
|
__version__ = "4.1.0.a5"
|
||||||
__codename__ = "Groundhog Day"
|
__codename__ = "Groundhog Day"
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,12 @@ from asyncio_mqtt import Client, MqttError, Will
|
||||||
from contextlib import AsyncExitStack, asynccontextmanager
|
from contextlib import AsyncExitStack, asynccontextmanager
|
||||||
from cbpi import __version__
|
from cbpi import __version__
|
||||||
import logging
|
import logging
|
||||||
|
import shortuuid
|
||||||
|
|
||||||
class SatelliteController:
|
class SatelliteController:
|
||||||
|
|
||||||
def __init__(self, cbpi):
|
def __init__(self, cbpi):
|
||||||
|
self.client_id = shortuuid.uuid()
|
||||||
self.cbpi = cbpi
|
self.cbpi = cbpi
|
||||||
self.kettlecontroller = cbpi.kettle
|
self.kettlecontroller = cbpi.kettle
|
||||||
self.fermentercontroller = cbpi.fermenter
|
self.fermentercontroller = cbpi.fermenter
|
||||||
|
@ -47,7 +49,7 @@ class SatelliteController:
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.client = Client(self.host, port=self.port, username=self.username, password=self.password, will=Will(topic="cbpi/disconnect", payload="CBPi Server Disconnected"))
|
self.client = Client(self.host, port=self.port, username=self.username, password=self.password, will=Will(topic="cbpi/disconnect", payload="CBPi Server Disconnected"),client_id=self.client_id)
|
||||||
self.loop = asyncio.get_event_loop()
|
self.loop = asyncio.get_event_loop()
|
||||||
## Listen for mqtt messages in an (unawaited) asyncio task
|
## Listen for mqtt messages in an (unawaited) asyncio task
|
||||||
task = self.loop.create_task(self.listen())
|
task = self.loop.create_task(self.listen())
|
||||||
|
|
Loading…
Reference in a new issue