Hi,
I am trying to access the Msg Object Key as a dynamic label for text label in a NodeRED Dashboard display but has difficulty in finding way to extract the "Key" value.
I have a MQTT data object stream that receives digital input status from a PLC and I need to display the respective "Key" text (e.g. Di1, Di2..) as label on the NodeRED dashboard. As these Key text are dynamic and changes, I cannot use static typed text for the {{label}}.
I tried to split the object "Key and Value pair" stream and is able to get the individual "Value" results.
However, I am stuck on how to extract each of the "Key" value as text to be submitting to the Dashboard Label.
Attached is my flow and dashboard for reference.
[{"id":"47616595f9d59619","type":"tab","label":"Flow 4","disabled":false,"info":"","env":[]},{"id":"99d62f342708aa0d","type":"mqtt in","z":"47616595f9d59619","name":"","topic":"v1/2158061268/DiM2/values","qos":"2","datatype":"json","broker":"db51a71cd38877ec","nl":false,"rap":true,"rh":0,"inputs":0,"x":180,"y":120,"wires":[["b36f9801a0c5787c","58cbfbf67defd0dc","27ad9e552208fd89","1d39b4bbe220122a"]]},{"id":"e2cff9f0e0ef72d1","type":"debug","z":"47616595f9d59619","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.params","targetType":"msg","statusVal":"","statusType":"auto","x":600,"y":120,"wires":[]},{"id":"b36f9801a0c5787c","type":"function","z":"47616595f9d59619","name":"","func":"var Dix = msg.payload.params.Di1;\n\nif (Dix == '1') {\n (msg.payload='ON')}\n else {\n (msg.payload='OFF')}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":220,"wires":[["48abc233580983c2","6b85fa7cbb345b13"]]},{"id":"48abc233580983c2","type":"debug","z":"47616595f9d59619","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":220,"wires":[]},{"id":"6b85fa7cbb345b13","type":"ui_text","z":"47616595f9d59619","group":"9a6348a506085d0e","order":1,"width":"3","height":"1","name":"Di1 Status","label":"Di1 (hardcode)","format":"{{msg.payload}}","layout":"row-center","className":"","x":610,"y":280,"wires":[]},{"id":"58cbfbf67defd0dc","type":"function","z":"47616595f9d59619","name":"","func":"var Dix = msg.payload.params.Di2;\n\nif (Dix == '1') {\n (msg.payload='ON')}\n else {\n (msg.payload='OFF')}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":360,"wires":[["6ee7759595ecadb3","a1c0c70ca4cacd6c"]]},{"id":"6ee7759595ecadb3","type":"debug","z":"47616595f9d59619","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":360,"wires":[]},{"id":"a1c0c70ca4cacd6c","type":"ui_text","z":"47616595f9d59619","group":"9a6348a506085d0e","order":1,"width":"3","height":"1","name":"Di2 Status","label":"{{label}}","format":"{{msg.payload}}","layout":"row-center","className":"","x":610,"y":420,"wires":[]},{"id":"27ad9e552208fd89","type":"change","z":"47616595f9d59619","name":"","rules":[{"t":"move","p":"payload.params","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":540,"wires":[["5a99ee725e91ef8d"]]},{"id":"5a99ee725e91ef8d","type":"split","z":"47616595f9d59619","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":470,"y":540,"wires":[["072b120e3313bf7b"]]},{"id":"1d39b4bbe220122a","type":"function","z":"47616595f9d59619","name":"","func":"msg.item = msg.payload[msg.index];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":120,"wires":[["e2cff9f0e0ef72d1"]]},{"id":"072b120e3313bf7b","type":"debug","z":"47616595f9d59619","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":540,"wires":[]},{"id":"db51a71cd38877ec","type":"mqtt-broker","name":"DAXView Mini SG","broker":"1160ee3168524d998cb5c33af5355c22.s1.eu.hivemq.cloud","port":"8883","tls":"","clientid":"E92m","autoConnect":true,"usetls":true,"protocolVersion":"5","keepalive":"70","cleansession":false,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"9a6348a506085d0e","type":"ui_group","name":"Di Status","tab":"8f41e4d6436371f2","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"8f41e4d6436371f2","type":"ui_tab","name":"Di Status","icon":"dashboard","disabled":false,"hidden":false}]
Any suggestion is greatly appreciated.
Best Regards,
KC