A bit of advice please. My system consists of Node Red running on a Raspberry Pi 4 receiving data from several Sonoff TH16's temperature sensors (which have been flashed with Tasmota). The data is sent via an MQTT broker. I'm using Node Red to run my heating system and turn a few other thing on and off.
Now, I don't want to disturb this setup as it's running well without errors but it would be nice to experiment a little. What I would like to do is take the same MQTT data from the Sonoff's and squirt that into an instance of Node Red running on my Windows 10 PC (I already have Node Red set up and running on the PC) Not quite sure if it's possible as the Sonoff's MQTT parameter page is specified as the Pi's IP address. Is there some way of sending MQTT data to two different computers (hosts) at the same time? Or re-broadcasting it in some way to another host?
MQTT has three parts - one or more publishers, a broker and one or more subscribers. So all you should need to do on the new Node-RED set the mqtt-in to point to the same broker (use the ip address) that the original NR is using.
If you want to learn more about MQTT then see this tutorial MQTT Essentials - All Core Concepts explained
MQTT is not Point to Point. When your Sonoff publishes a message it does not say "This message is for Node-red on my Raspberry Pi"
Just subscribe to the messages from Node-red on your PC.
ps Why do you need Node-red running on the PC as well as on a Pi? You can view the editor/dashboard from any browser in your network.
In general, you have one MQTT broker (server) on a network and things publish data to topics on it and other things subscribe to those topics and the broker updates everybody with the information they've asked for
So, on your PC , all you need do is connect and subscribe to your existing broker to get the same information on it
HOWEVER, your existing broker might be in a walled Docker garden or it may not be configured to allow access from any IP address
Are you able to access the computer its running on and cd into /etc/mosquitto?
Jbudd. To answer your question, I just want to experiment with the flows and optimise the control of my heating whilst observing its effects without disturbing the original control flows on the Pi. I dont want to risk breaking anything whilst the weather is quite cold.
Just set up your test node-red instance to listen to the live data but process it differently. Nothing else needed. The test instance will have no measurable impact on the MQTT broker and since it is only listening, can have no impact on your live processing.
If you want to experiment with a different MQTT topic structure, use your test node-red instance to republish the live data to the new topics. Use a separate flow on the test instance to process those topics.
You can also install MQTT Explorer on a computer to watch what is happening.
Thanks for the guidance chaps. Didn't think it was going to be so easy. I just added an MQTT input node into the flow on my Windows PC, gave it the address of my Raspberry Pi and hey presto, data's coming in thick and fast.
Well chuffed. Now I can play around with a more exotic control scenario including trying out a bit of PID without affecting the working system.
Once again this forum shows what a wonderful and helpful community we are a part of.