I want to use the name of a node later in a flow, is this possible?
When yes, how can i do this?
I am using a zigbee2mqtt node and give it an understandable name.
This name will be used to commit a record in a database.
Thus not having to keep track of redundant information.
A long time ago I think someone gave me some JSONata that extracts the name of the node
If this is true, then you could add an JSONAta expression to stick it in something like msg.InjectName
I'll try some searching ....
[edit] In retrospect, it might have been that a function node can access the name through node.name but I don't know if it can be done using JSONata
The name will then be used ( i am an new beginner with javascript!!! ) here:
let obj = [];
let payload = msg.payload;
let ieee_address = msg.device["ieeeAddr"];
let friendly_name = msg.device["friendly_name"];
let location = "office"; /* <- i want the node name here */
obj.push(payload);
obj.push({ieee_address,
friendly_name,
location});
msg.payload = obj;
return msg;
This pushes the data into influxdb with the name in the committed record.