Using global in a node (that's not a function node)

I have some globals declared in functionGlobalContext (example):

functionGlobalContext: {
led_light: 'light.my_led_light'
},

In a "function" node, I can do a global.get('led_light'), and this works fine. I wanted to use the same global in other nodes that are not "function" node. So I thought that this, {{global.led_light}}, use to work in nodes where Entity ID is required. But after an upgrade to 1.3.5, this no longer works. Does anyone know if I was mistaken, and this never worked in the first place? Or the feature was somehow changed/deprecated? Thanks.

Hi @wiiNinja

It depends on what specific nodes accept - it isn't a general pattern used throughout Node-RED.

Which nodes are you trying to use it in?

I think you're right; I did some experimenting and it does work in some nodes. I am mainly using the nodes in "Home Assistant". Examples: This pattern works in the "call service" nodes, but does not work in the "event:state" nodes. Do you have a suggestion for how to parameterize the Entity ID in these nodes such that when a change needs to be made, I don't have to touch all the affected nodes? Thanks for your response.

Sorry, I don't have any experience of the HA nodes. You may need to ask in the ha forum unless someone else here knows the answer.

I seem to remember helping another HA user and there is a option to use jsonata
so $globalContext("thevar") might work if my memory is correct.

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