Pulling helpers into node-red global variables. Is there a better way?

I currently have a node-red flow that injects a message every 5 minutes which gets the current status of a few input_text helpers which then flow into a change node that sets the payload to global.gvarsomename for example.
When a node needs to act on the value of this variable, I then reference {{global.gvarsomename}} which works great.
I guess I could use a poll node for each variable, but redoing this to reduce 1 node isn’t worth it. I’d like to just get rid of the whole flow.

Is there another way to reference these helper values with something like {{hainputtext.somehelpername}} without triggering the flow I described? I’d like the values to be updated immediately on updating the helper, rather than waiting 5 minutes or polling them every second.

There is no need to poll or store home assistant states they are already all there. They’ll update when updated in HA. You can access them in home assistant nodes using:

$entities("sensor.name_here").state
## If you need to return a number, some are stored as strings, to convert use
$number($entities("sensor.name_here").state)

In change nodes set drop down to global.
and use
homeassistant.homeAssistant.states["sensor.name_here"].state

2 Likes

Thanks, this is around what I’m looking for. I got it working with the below

{
    "media_content_type":"playlist",
    "media_content_id":"plex://{\"plex_server\": \"{{global.homeassistant.homeAssistant.states["input_select.plex_server"].state}}\", \"playlist_name\": \"{{global.homeassistant.homeAssistant.states["input_text.playlist_wake_up"].state}}\", \"shuffle\": 1}"
}
1 Like