# Variables with a dot in the name

**URL:** <https://discourse.nodered.org/t/variables-with-a-dot-in-the-name/20478>\
**Category:** General\
**Created:** [17 January 2020 06:47 UTC](https://discourse.nodered.org/t/variables-with-a-dot-in-the-name/20478 "2020-01-17T06:47:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisV](https://avatars.discourse-cdn.com/v4/letter/c/f9ae1b/32.png) [@chrisV](https://discourse.nodered.org/u/chrisV)\
**Post date:** [17 January 2020 06:47 UTC](https://discourse.nodered.org/t/variables-with-a-dot-in-the-name/20478/1 "2020-01-17T06:47:06Z")

</div>

Hi,  
In HomeAssistant, I want to read the value of a global variable that has a dot in the name  
As an example, I want to:  
`global.get("homeassistant.MyHomeAssistant.states.sun.sun.state");`  
The problem is the name of the variable `sun.sun` That dot in the name of the variable gets interpreted as another object (which is expected)  
How can I "escape" that dot in the above expression?  
I tried several ways, but without any luck.  
Any tips are welcome,  
thanks,  
chrisV

---

<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:** [17 January 2020 07:09 UTC](https://discourse.nodered.org/t/variables-with-a-dot-in-the-name/20478/2 "2020-01-17T07:09:13Z")

</div>

You can try:

```auto
global.get("homeassistant.MyHomeAssistant.states['sun.sun'].state")

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 January 2020 09:54 UTC](https://discourse.nodered.org/t/variables-with-a-dot-in-the-name/20478/3 "2020-01-17T09:54:29Z")

</div>

Can you change the name of the variable in HomeAssistant? That would seem to be a better solution

---

<div class="post-metadata">

**Author:** ![chrisV](https://avatars.discourse-cdn.com/v4/letter/c/f9ae1b/32.png) [@chrisV](https://discourse.nodered.org/u/chrisV)\
**Post date:** [17 January 2020 10:50 UTC](https://discourse.nodered.org/t/variables-with-a-dot-in-the-name/20478/4 "2020-01-17T10:50:55Z")

</div>

> [@knolleary](#):
>
> global.get("homeassistant.MyHomeAssistant.states['sun.sun'].state")

Thanks ! I had seen this alternate syntax, but I missed the trick with the single quotes. Also, I had a dot before the [...]; which was not good.  
Learned something new here 🙂

> [@zenofmud](#):
>
> Can you change the name of the variable in HomeAssistant? That would seem to be a better solution

Unfortunately those are predefined names by HomeAssistant. Those variables are created by HomeAssistent and represent the states of the different sensor.

Thank you both, problem solved and something learned  
chrisV
