wait for broker to be started
This commit is contained in:
parent
6a58d8fb7f
commit
240a66155f
2 changed files with 15 additions and 14 deletions
|
|
@ -110,20 +110,18 @@ async def start():
|
|||
global xmpp_server
|
||||
xmpp_server = XMPPServer((bumper_listen, xmpp_listen_port))
|
||||
|
||||
# Start MQTT Server
|
||||
# await start otherwise we get an error connecting the helper bot
|
||||
await asyncio.create_task(mqtt_server.start())
|
||||
|
||||
# Start MQTT Helperbot
|
||||
asyncio.create_task(mqtt_helperbot.start())
|
||||
|
||||
# Start XMPP Server
|
||||
asyncio.create_task(xmpp_server.start_async_server())
|
||||
|
||||
# Wait for helperbot to connect first
|
||||
while not mqtt_helperbot.is_connected:
|
||||
# Start MQTT Server
|
||||
# await start otherwise we get an error connecting the helper bot
|
||||
await mqtt_server.start()
|
||||
while not mqtt_server.state == "started":
|
||||
await asyncio.sleep(0.1)
|
||||
|
||||
# Start MQTT Helperbot
|
||||
await mqtt_helperbot.start()
|
||||
|
||||
# Start web servers
|
||||
await web_server.start()
|
||||
|
||||
|
|
|
|||
|
|
@ -52,11 +52,14 @@ class HelperBot:
|
|||
async def _on_message(
|
||||
client: Client, topic: str, payload: bytes, qos: int, properties: dict
|
||||
) -> None:
|
||||
_LOGGER.debug("Got message: topic=%s; payload=%s;", topic, payload.decode())
|
||||
topic_split = topic.split("/")
|
||||
data_decoded = str(payload.decode())
|
||||
if topic_split[10] in self._commands:
|
||||
self._commands[topic_split[10]].add_response(data_decoded)
|
||||
try:
|
||||
_LOGGER.debug("Got message: topic=%s; payload=%s;", topic, payload.decode())
|
||||
topic_split = topic.split("/")
|
||||
data_decoded = str(payload.decode())
|
||||
if topic_split[10] in self._commands:
|
||||
self._commands[topic_split[10]].add_response(data_decoded)
|
||||
except Exception:
|
||||
_LOGGER.error("An exception occured during handling message.", exc_info=True)
|
||||
|
||||
self._client.on_message = _on_message
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue