I started working on this a few days ago for my son, who wants to use a Raspberry Pi (or 2) to monitor and control a model railroad layout. This is a write up to get him started. In this demo environment, I have HS4-Pi running on a Pi-400 and Node-RED running on a 3B. The GPIO connections are on the 3B. There's a jumper wire between GPIO20 (Out) and GPIO21 (In). I will use an HS Device with two features for this demo.
Create a new HS device which will result in a Root Device and a Feature Device. The feature will have controls we will use to control the GPIO20 output. Set the Status/Graphics tab for the feature as follows:

Next, use Bulk Edit to make a copy of the feature and set its Status/Graphics tab as follows:

Basically, just delete the controls for the monitoring device. That's it for the HS Device setup.
Now onto Node-RED. Again, Node-RED is running on a 3B and HS4-Pi on a Pi-400 but it could be on the same Pi. The key is that this flow needs to be running on the Pi you want to monitor and control. Here's the complete flow:

Here's the output control nodes:



And the monitoring input nodes:



Now, when you click on the Low/High buttons on the control device, the GPIO output will be set Low or High. Since it's jumped to the GPIO Input, you'll see the monitoring device change as well.

Use Bulk Edit to make copies of the input/output features and duplicate/edit the input/output nodes for additional GPIOs.
Feel free to ask questions.
Ken
Create a new HS device which will result in a Root Device and a Feature Device. The feature will have controls we will use to control the GPIO20 output. Set the Status/Graphics tab for the feature as follows:
Next, use Bulk Edit to make a copy of the feature and set its Status/Graphics tab as follows:
Basically, just delete the controls for the monitoring device. That's it for the HS Device setup.
Now onto Node-RED. Again, Node-RED is running on a 3B and HS4-Pi on a Pi-400 but it could be on the same Pi. The key is that this flow needs to be running on the Pi you want to monitor and control. Here's the complete flow:
Here's the output control nodes:
And the monitoring input nodes:
Now, when you click on the Low/High buttons on the control device, the GPIO output will be set Low or High. Since it's jumped to the GPIO Input, you'll see the monitoring device change as well.
Use Bulk Edit to make copies of the input/output features and duplicate/edit the input/output nodes for additional GPIOs.
Feel free to ask questions.
Ken
Comment