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

**URL:** <https://discourse.nodered.org/t/using-global-in-a-node-thats-not-a-function-node/46746>\
**Category:** General\
**Created:** [5 June 2021 16:44 UTC](https://discourse.nodered.org/t/using-global-in-a-node-thats-not-a-function-node/46746 "2021-06-05T16:44:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wiiNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wiininja/32/42889_2.png) [@wiiNinja](https://discourse.nodered.org/u/wiiNinja)\
**Post date:** [5 June 2021 16:44 UTC](https://discourse.nodered.org/t/using-global-in-a-node-thats-not-a-function-node/46746/1 "2021-06-05T16:44:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [5 June 2021 17:04 UTC](https://discourse.nodered.org/t/using-global-in-a-node-thats-not-a-function-node/46746/2 "2021-06-05T17:04:44Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![wiiNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wiininja/32/42889_2.png) [@wiiNinja](https://discourse.nodered.org/u/wiiNinja)\
**Post date:** [5 June 2021 17:22 UTC](https://discourse.nodered.org/t/using-global-in-a-node-thats-not-a-function-node/46746/3 "2021-06-05T17:22:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [5 June 2021 17:29 UTC](https://discourse.nodered.org/t/using-global-in-a-node-thats-not-a-function-node/46746/4 "2021-06-05T17:29:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [5 June 2021 17:31 UTC](https://discourse.nodered.org/t/using-global-in-a-node-thats-not-a-function-node/46746/5 "2021-06-05T17:31:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 August 2021 17:32 UTC](https://discourse.nodered.org/t/using-global-in-a-node-thats-not-a-function-node/46746/6 "2021-08-04T17:32:06Z")

</div>

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