Is there a way to get node properties Name and use it later in the flow?

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.

Thanks, Peter

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 but I don't know if it can be done using JSONata

In a function node this works to get it's node name:

msg.payload =
return msg;

A picture says more than ... :slight_smile:

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 */


msg.payload = obj;

return msg;

This pushes the data into influxdb with the name in the committed record.

Cheers, Peter

This is no way to access the name property of a node earlier in the flow.

But you could pass the message through a change node which adds msg.source = "garage door"

Not exactly what i had in mind, but as a workaround it works for me.

Thank you !

Just found out that i can set the friendly_name in zigbee2mqtt.
This will fix it without a hassle...

Using friendly_name has drawback as well, so please bring on workarounds or a solution.

Thanks, Peter

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