Obtain helper entity value in node red function

hi everyone, for obtain a helper value in a function i´m using this code but i think puse that is very complex and probably there was another basic code the obtain the value of a entity

counter = global.get("homeassistant").homeAssistant.states['counter.counter_1'].state;
text = global.get("homeassistant").homeAssistant.states['input_text.label_1'].state;

Thanks!!

Depends on what you’re trying to do with said entity…

If you’re using it inside a function. You’re good. That’s the correct way to reference an entity using the NR object model.

You could also just plop an appropriate entity node in your flow. Again, depending on your use case.

Thanks Nathan, i know that i can answer for the device state in the flow with current state node but
i want compose a phrase with differens states of devices to send by message and if for it i program in the function module directly

Then that should do nicely.

1 Like