-
Hello all, I am working on my dashboard. The goal is to visualise data that are received by an mqtt-broker. I do not really found something in the docs about mqtt connections... So my question is: Does someone has an idea about connecting niceguy with mqtt. best regards, Linus Discord: Linus#2222 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Here is one very dirty and hacky solution i found: async def connect_mqtt():
mqtt_handler = MQTTHandler(
hostname="127.0.0.1",
port=1883,
client_id="demo_id",
message_handler=on_message,
)
mqtt_handler.connect()
mqtt_handler.subscribe("demo")
while mqtt_handler.is_connected:
await asyncio.sleep(1)
def on_message(payload):
print(payload["topic"])
app.on_startup(connect_mqtt)
ui.run(
host="127.0.0.1",
port=8080,
title="ALPHOS",
) |
Beta Was this translation helpful? Give feedback.
-
NiceGUI is based on FastAPI. So maybe https://github.com/sabuhish/fastapi-mqtt is what you are looking for? What is your goal? Do you want to create a user interface to send/receive mqtt messages? Do you have a running example without UI? Ideally with a public broker so anyone here can try it. |
Beta Was this translation helpful? Give feedback.
Here is one very dirty and hacky solution i found: