Receive msg from mqtt to html

hi , i really glad for help
i started learn nodered and i have a problem when i try to send a message from the mqtt to the html. the html web not stop loading , the problem is in idPerson node , but i dont know what i do wrong.

Put a seperate debug nodes (all set to display the 'Complete msg object') on the outputs of the 'MyPage', 'Openvm/test' and idPersion' nodes so you can see what is coming out of each node.

You can also add some node.warn('dgb1'+msg.topic) in your function node (you can use any variable in the function node) so you can see what is happening.

hi , thank you for your answer , i try it but still i cant figure why the page not load,
i try to add the case of "undefined" but still not working

Nati, so the debug is showing that msg.topic 'undefined'.
1 - Why do you think that is?
2 - If you look at the debug, do you 'topic' a part of the msg object?
3 - which node is this debug attached to? (if you put your cursor over the debug data in the sidebar, the debug node it is from will be outlined in a red dashed line)

I’m afraid the flow you’ve imagined won’t work in practice. This debug message is coming from the http-in node feeding into your function, as can be seen by the req and res properties on the object. The msg.topic you’re looking for would come from the mqtt-in node wired to the same function node. While I think I understand what your goal is, can you try to explain what your flow is supposed to do, in general terms rather than flow specific.

As for your function node shown here, rather than msg.topic holding the string "undefined", it is undefined. I explained the difference in another topic. In there, your string"undefined" would be non-zero value while the undefined seen here is the last one.


hi thank you for your response ,

  1. its happen because the http-in node , this node give undefined and go to the function idPerson .
  2. no
    3.the node is mypage(http-in)

hi thank you for your response ,

the flow supposed to do:
the mqtt give a string (some number) this number go to the sql and return the name that attached to the number that i got from the mqtt , and then the name go to the page ,

So now you know why you get the undefined. Becase you have two nodes that can start the flow independently of each other and since the http-in node doesn't have a msg.topic, the switch condition in the function node will not trigger - in that case. (You should remove the 'undefined' case)

why not use the node-red-dashboard to display the name and get rid of the http-in and http-out nodes?


hi , ok so how can i send a string that dependent on what mqtt output to the web page

and about the dashboard i prefer to do my own web

How is the mqtt-in being triggered - i.e. what action causes a mqtt-in msg to arrive?

If you want to start from the bare bones then maybe this example -

For something more sophisticated but also lets you build from scratch then look at the node-red-contrib-ui-builder project.

thank you!! ,this is what i need , and its work :smile: :smile: :smile:

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