Hi all,
So the problem I have been trying to solve is that I need differing UIs for different people and scenarios.
Here are two examples.
-
My partner tends to use the system differently than I do. I have created a simplified UI just for them, that prevents them from accessing pages that are available in my UI.
-
The UI available from the display in the lounge is purpose-made for that room such that my kids cannot f with each other by turning lights off when the other is in the shower/toilet elsewhere in the house.
My solution is described below, but I would like to hear yours.
Short version: build each GUI in a unique instance of Node-Red, running in ProxMox or similar VM/LXC manager, all sharing the same MQTT broker. This only works because ProxMox makes infinite servers on one physical machine possible.
Obvious, right? I learn slowly, OK? so I'm posting this because it's such a basic, core part of how MQTT works that it took me years to learn it. Shut up.
Long version:
My home's instance of Node-RED runs in ProxMox, in a Debian LXC. It is a system that relies entirely on MQTT messages that pass through Mosquitto, itself running in a separate ProxMox LXC. That means the GUI updates via MQTT too.
My tiny brain eventually twigged that because of this, the dashboard does not need to be running in the same Node-RED instance that does all of the thinking and automation. The commands a GUI gives are published to MQTT, and it visually updates via MQTT.
So when I need a separate GUI, I simply spin up another Node-RED LXC just for that purpose. It's a vanilla Node-RED with Dashboard and no other plugins, is computationally negligible, and is saved as a template so that I don't even need to install Node-RED or the Dashboard plugin when I want one. It's simply there in 15 seconds or so (my server is an old NUC).
On that instance, I build the required custom GUI, which obviously has its own unique IP address.
This method gives me unlimited unique GUIs, because each one speaks via MQTT to the same broker. Changes in one GUI replicate to all, because it's MQTT.
I am 100% sure that this will be totally obvious to many people reading this. But I am a bear of very little brain, and it felt like an epiphany, since I have needed this functionality for some time.
It would make no sense without the ability to trivially spin up servers.