How to inject entity id into message?

Hi,
I get a notification when someone opens a window, but I don’t know which sensor is triggered. Is there a way to insert entity id into notification? This is the flow I’m using:

thanks

I use this in my formula to achieve this:


newmsg = {}

newmsg.payload = { data: { "message":"Unregelmäßigkeit bei " + msg.data.new_state.attributes.friendly_name + " wurde erkannt"} }

return newmsg;
1 Like

I wrote this a long time ago, so I think they have standardized the message object, so there’s probably excess here, but this is what I use:

if(msg.data.attributes){
    msg.entity = msg.data.attributes.friendly_name;
} else if (msg.data.new_state) {
    msg.entity = msg.data.new_state.attributes.friendly_name;
}
return msg;

Then I have an object I can reference later in the flows (this one actually comes from a subflow) of msg.entity

1 Like

thank you both, will give it a try and see if I can make it work!

worked like a charm! Thanks