Just to follow up on this, it was surprisingly easy once I had the hint.
What I did was
- create a file node which accesses /usr/local/lib/node_modules/node-red/package.json attached to the startup trigger.
- The output is then passed through a json node
- then a function node has access to the version number as msg.payload.version which I stash in a context object
- I use the collected values at startup to send as json over MQTT to report on the device's status/health/uptime/version/ip/mac/subdevices etc to the broker.
Code below.
Thanks for the help, Nick
Ben
[{"id":"347f0afc.cb80f6","type":"file in","name":"Package file","filename":"/usr/local/lib/node_modules/node-red/package.json","format":"utf8","x":453,"y":303,"z":"3feb2ac7.c014d6","wires":[["216d0ef2.de92f2"]]},{"id":"216d0ef2.de92f2","type":"json","name":"","x":610,"y":305,"z":"3feb2ac7.c014d6","wires":[["4d59a194.b2a66"]]},{"id":"4d59a194.b2a66","type":"function","name":"Export Nodered version","func":"// Add node red version number to device object\ncontext.global.noderedversion = msg.payload.version;\n\nreturn msg;","outputs":1,"valid":true,"x":810,"y":299,"z":"3feb2ac7.c014d6","wires":[[]]}]