Extract a Substring from msg.payload and use it as a variable for global.set?

Hi,

is there a chance to extract a value from a string, e.g.

tele/SP111_131308/#

(i need the value between the slashes)

and would like to use it as a global Variable:

global.set ("SP111_131308.State", msg.payload.Switch_State);

Is this even possible in NR ?
BR
Gawan

let topic = msg.topic.split("/")[1];
global.set (topic + ".State", msg.payload.Switch_State);
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.