Help inserting an entity state into an output

Hi All, just wondering if anyone can assist me, basically I have the below flow setup that tracks my phones location until I hit certain zones on the way to someones house and sends them a message in discord saying basically im round the corner.

I’ve recently discovered the Waze Travel time integration and setup an entity that will give an ETA to said persons house, I’d like to put this in the message that gets sent at the first step when my phone goes from home to not_home.

Does anyone know how I can modify this step to include the state of the waze travel eta.

Any help is much appreciated :smile:

I haven’t used the Waze Travel Time integration, but assuming it creates an entity, you would use a current state node to load the state into whatever msg property you want (overriding it from the default of payload and data). Then you would use a change node to combine the distance with the message you want to send.

1 Like

Add another msg output


idk if that is the message path, change as needed.

1 Like

Thanks for the suggestions!

I ended up spending some time and using chatgpt to try and figure it out. The way I got it to work is to remove the msg.payload from the wait until node and add a new current state node to get the eta and put that into a function.


var entityState = msg.payloadeta; // Accessing state directly from msg.payloadeta
var user = msg.user; // Assuming user information is stored in msg.user

// Format the message
var message = "Just leaving mine now, I will be at yours in roughly " + entityState + " minutes";

// Set the formatted message and user as payload
msg.payload = message;
msg.user = user;

// Return the modified message
return msg;

I’m sure this is probably not an efficient way to do it but its how I ended up getting it working :slight_smile:

Using $entities("sensor.my_sensor") you can dynamically get the state and attributes of any entity in HA using the Jexpression option

1 Like

Yea I saw that on your response and I was already down a bit of rabbit hole haha, I was struggling with how to format the message that feeds into the discordmessagemanager to show the text I wanted and the entity state.

I’m sure it was something really simple that I was just missing and I’ve probably gone really around the houses with my solution but I’m new to Node-red so very much still learning

1 Like

NP, I understand. Here is a guide with examples on ways to use message data.