Hello Community,
I use MQTT protocol for my system.I have a lot of rpi and I use a dynamic post but the properties WagDog is not dynamic.
Ex:
rpi 1 the topic is RPI1/Input
RPI1/Watchdog
rpi 2 the topic is RPI2/Input
RPI2/Watchdog
...
...
...
rpi X the topic is RPIX/Input
RPIX/Watchdog
Is it possible to make this properties dynamic?
Thank you
Most aspects of the MQTT nodes are dynamic (including setting LWT) however you don't really need that complexity.
Just use env vars instead.
E.g. ${MQTTLWT}
https://nodered.org/docs/user-guide/environment-variables
Ok I understand the principle but not the method of writing.
Could I have an example of flow?
Um. Not really practical TBH.
Here is a minimal procedure:
- set an environment variable named
MQTTLWT to the value RPI1/Watchdog in PI 1
- set an environment variable named
MQTTLWT to the value RPI2/Watchdog in PI 2
- set an environment variable named
MQTTLWT to the value RPIn/Watchdog in PI n
- change the MQTT config "Messages" topics from
RPI1/Watchdog to ${MQTTLWT}
- (re)start node-red on all the PIs
As for how to set an env variable - this is an operating system specific thing (but there are LOTS of docs, tutorials and vides around the net - just search "set permanent environment variable debian")