Good Morning! In my previous post on using mqtt with Node-Red, @mytechtrail had asked how to add different tabs for the different flows that could be on separate Pi's. Additionally I'll share with you a public mqtt broker that you could use if you wanted to control your flows from anywhere without having to open a port in your firewall. I know enough about security to know that I don't have the skills to be opening ports while keeping the bad guys at bay! (grin)
To add the hivemq broker double-click on the pink mqtt node and click on the down arrow on the Server box and select "Add new mqtt broker". Now click the pencil button to the right.
Don't forget to set the same broker and topic on the incoming mqtt node.
Deploy the changes and double check that your GPIO pin is going high & low as you move the switch on and off. You are now sending your mqtt message out to their public broker and you have subscribed to it and are receiving it back. If you want to manually test the message you can use their online browser client to publish messages to your topic and verify that you are receiving them.
Click on the pencil and rename your new tab "Away" and click Add
Rename the second group from "Default" to "My Second Group" and click Add
Now your switch node should have a Group of [Away] My Second Group and click Done
Click on the mqtt node and set the server to "HiveMQ", the topic to something new "testtopic/robin2" and the QOS to 2 for assured delivery, and click Done
Do the same for the mqtt in node
And set the GPIO pin to your desired number, and don't forget to select "Initialize pin state" if you want it to start in a Low or High state, and click Done
All the red triangles should be gone indicating that you configured all of the nodes and the blue circles will disappear once you've deployed the changes
You did remember to deploy the changes right? (grin)
Now when you goto the UI "yourPiAddress:1880/ui" and click on the 3 bars beside the Home tab in the upper left corner you should see Home and Away (the new tab you've created)
Selecting "Home" brings up the GPIO24 switch in "My First Group"
And selecting "Away" brings up the second switch in "My Second Group".
Hopefully this has shown you how you can add access to many of your different devices through Node-Red and because we are using mqtt we can control the outputs or receive input from Node-Red devices and the Pi ZeroW's running their python3 code.
Thanks for viewing!
Robin