lowcoder icon indicating copy to clipboard operation
lowcoder copied to clipboard

[Feature request]: add MQTT client support

Open jerome83136 opened this issue 1 year ago • 4 comments
trafficstars

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] I'm trying to build a smart home dashboard with an interactive floor plan that contains icons representing the state of connected devices (light bulbs, etc...) Example use case:

  • I switch a light bulb OFF by using the "physical" button of the corresponding wall switch.
  • The switch sends a message to my central MQTT broker and the light bulb goes OFF.
  • I would like the state of the icon representing the light, to be updated within the application. (without having to refresh the page)

NB: my switches are connected. So when I change their state with the physical buttons; an MQTT message is sent to my central MQTT broker.

Describe the solution you'd like A clear and concise description of what you want to happen. Add a MQTT client to Lowcoder; so that it can subscribe to MQTT topics, watch for new messages and trigger internal components updates accordingly.

Describe alternatives you've considered

  1. Idea1: My wall switchs are using Tasmota firmware; so they expose an API for querying the state of the switch. I tried executing a query from Lowcoder to get the state of my wall switchs and update the light icon within my application. It works if I trigger the query manually from within the application. But it doesn't work if I force the query execution by using this POST request: http://lowcoder_docker_host:3000/api/v1/query/execute (the query is successfuly executed and I see the Tasmota API answer; but nothing happens on the application)

  2. Idea2: Maybe could we use Lowcoder's REST API to force updating the state of a component/components group from the oustide of the application ?

Additional context Basically; my main need is to make Lowcoder aware of events occuring externally from the application's point of view.

Thank you for your help & feedback. I hope it can be useful for other people requiring MQTT :)

Best regards

jerome83136 avatar Mar 08 '24 17:03 jerome83136

Screenshot 2024-03-09 at 14 28 33 As a question... We do have the Stream Query, making use of Websocket Connections. It is not MQTT - but offers the same possibility to subscribe to changes in a Data Stream.

Would that be sufficient? We can additional integrate https://github.com/mqttjs/MQTT.js soon. However, we wanted to ask, if Websockets can satisfy your need already, so you would not be blocked by waiting.

FalkWolsky avatar Mar 09 '24 13:03 FalkWolsky

Hello, Yes, websocket can solve the issue I just need to learn how to implement it with my MQTT broker (I'm using emqx) and how to use stream queries (as I'm quite new to lowcoder) But I think it could work Anyway, I also think adding MQTT support on lowcoder could be a great addition 😊 I will post here my progress on websocket, to share any useful knowledge with others 😊 Thank you for your support Best regards

jerome83136 avatar Mar 09 '24 23:03 jerome83136

Hi all, @FalkWolsky thank you for the tip ! I was able to realize what I need bu using "Query stream" as you advised !

For other people trying to achieve similar things; here is a short description of what I did:

  1. Used a "websocket in" node on NodeRed and exposed it on the following URL: ws://domotique.maison.lan/nodered**/mqtt**
  2. Used a "MQTT subscribe node" on NodeRed and configured it to subscribe to the topic receiving my lights status (from my Tasmota wall switchs)
  3. Used a "websocket out" node on NodeRed to notify websocket clients about new messages published in the related topic on my broker
  4. Subscribed Lowcoder query stream on my NodeRed websocket endpoint by targeting: ws://domotique.maison.lan/nodered/mqtt

So the logical flow is: [Lowcoder query stream] --> [NodeRed websocket in] --> [NodeRed MQTT subscriber] --> [NodeRed websocket out] --> [Lowcoder query stream]

NB: I finally implemented webocket in NodeRed because I already use it for other purposes and it allows me to integrate it with other components of my smart home setup.

Here is how the configuration looks like on myLowcoder test app:

image

We can see here that a message containing payload: OFF (and not only) was received on the query stream and the message (with payload: OFF ) was displayed on the "test1" Text component. (of course we can postprocess the message to format it and filter the attributes we don't want to use o the rest of the Lowcoder pipeline. Here I just did a quick&dirty test :) )

Testing: publish a message to the subscribed topic and check if the message is received on Lowcoder. (here I asked Lowcoder to show the received message on a "Text" component (test1)

Using NodeRed for this is not mandatory (it only makes sense for my custom setup); but you can directly use websocket by activating it on your broker's configuration and configure Lowcoder to point to it directly.

Here are examples:

I hope it will help others :)

Thanks to this I was able to achieve exactly what I needed; but I also think that adding native MQTT support inside Lowcoder could be a great addition :)

Thank you again for your help and for keeping Lowcoder alive ;)

jerome83136 avatar Mar 11 '24 13:03 jerome83136

Hi, After playing a lot with websocket as a workaround; I still think a "true" mqtt support is valuable. Are there any plans to achieve it? Thank you for your feedback Best regards

jerome83136 avatar Jan 26 '25 17:01 jerome83136

Hi there, Is this feature planed to be implemented ? Thank you Best regards

jerome83136 avatar Jul 25 '25 12:07 jerome83136

I gave up with lowcoder and switched to home assistant dashboard with pictures-elements that does everything I need

jerome83136 avatar Sep 22 '25 15:09 jerome83136