Node-RED : MQTT subscribe on generic topic
Tagged: Node-RED
- This topic has 6 replies, 2 voices, and was last updated 8 years, 9 months ago by 
Claude Favreau.
 
- 
		AuthorPosts
 - 
		
			
				
January 27, 2017 at 5:53 am #16488
Claude Favreau
ParticipantHi,
I post a message because I didn’t really find a solution about my problem. I am developing a generic flow on Node-RED that I could deploy on severals gateways. What I am trying to do is to receive some messages on a MQTT topic that I subscribed. But I didn’t find a good way to have a generic “topic” like this :
gateway/{serialNumber}/input
Where the serial number is automatically filled. Someone has had to do this stuff ? Today my solution is to create a custom MQTT node but I would like to know if there are not better solution.
Regards
January 27, 2017 at 9:16 am #16503Peter Ferland
BlockedFor MQTT topics the wildcard is ‘+’ so if you wanted to subscribe to every gateway’s input topic you would use “gateway/+/input”.
If you wish to put your own string there for a specific gateway’s serial number, you’d need to build the string in a javascript node and then set the string as the topic property in the msg.
January 27, 2017 at 9:47 am #16505Claude Favreau
ParticipantHi,
Yes I am agree with you but I wouldn’t to have many charge on gateways. Therefore, to avoid this problem I need to subscribe a specific topic with the serial number for each gateway. For an input mqtt node we canot give a topic like you told me.
I think the way is to have a custom node if I want to insert the serial number from each gateway dynamically. But I would like to be sure.
Regards
January 27, 2017 at 9:53 am #16507Peter Ferland
BlockedFor a MQTT input node you are correct, there is no way to programmatically set the topic on an input using the built in nodes so you would have to create a custom node to handle that.
January 31, 2017 at 10:27 am #16581Claude Favreau
ParticipantHi,
Thanks very much. I have another question linked to this post. Do you know how to create a custom Node-RED app ? Because if I overwrite or I add a custom node for MQTT, I would like to have the possibility to deploy it on severals gateway easily.
Regards
January 31, 2017 at 10:40 am #16582Peter Ferland
BlockedThere is extensive discussion on adding nodes to node-red on the Conduit in this thread: http://www.multitech.net/developer/forums/topic/adding-nodes-to-node-red/page/2/
Once you figure out what commands need to be run, you can execute them in the install script in a custom application package and use DeviceHQ to deploy the custom application to each of your gateways. http://www.multitech.net/developer/software/aep/creating-a-custom-application/
February 3, 2017 at 6:24 am #16659Claude Favreau
ParticipantHi,
Thanks, it helps me in what I want to do.
Regards
 - 
		AuthorPosts
 
- You must be logged in to reply to this topic.