Communicate between UI and MQTT

Hello all, I want to send a payload (for exemple : true) to a uibilder node and based on that payload, I want the javascript code inside the uibuilder to read it and use a condition on it.
If I have to use socket, how does that work?

Hi Emna, uibuilder does all the hard work for you. You don't need to mess with sockets since the uibuilder node does the server part and the uibuildefe library does the client part.

As long as you've loaded the client library and run uibuilder.start(), comms should be working. You can confirm that by connecting a debug node to the lower output port on your uibuilder node. You will see the startup messages coming from the client when it connects. You will also see the connected client count change on the node itself.

Inside your front-end code, you need a listener function:

uibuilder.onChange('msg', (msg) => {
    console.log('New msg from Node-RED: ', msg)
})

Please do check out the beginners guide which is part of the Tech Docs that you can access from GitHub or from any of your deployed uibuilder nodes.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.