# Check if a logic variable is / is not NULL?

**URL:** <https://community.homey.app/t/check-if-a-logic-variable-is-is-not-null/66651>\
**Category:** Questions & Help\
**Tags:** flow\
**Created:** [July 29, 2022, 6:51am UTC](https://community.homey.app/t/check-if-a-logic-variable-is-is-not-null/66651 "2022-07-29T06:51:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joka](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Joka](https://community.homey.app/u/Joka)\
**Post date:** [July 29, 2022, 6:51am UTC](https://community.homey.app/t/check-if-a-logic-variable-is-is-not-null/66651/1 "2022-07-29T06:51:43Z")

</div>

How can I check if a variable/tag is / is not NULL/empty with a logic condition card?

THX

---

<div class="post-metadata">

**Author:** ![FKey](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fkey/32/14793_2.png) [@FKey](https://community.homey.app/u/FKey)\
**Post date:** [July 29, 2022, 6:55am UTC](https://community.homey.app/t/check-if-a-logic-variable-is-is-not-null/66651/2 "2022-07-29T06:55:54Z")

</div>

Can it be NULL/empty??  
When you create a variable you have to fill the default.  
When you restart homey that value is set.

---

<div class="post-metadata">

**Author:** ![Joka](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Joka](https://community.homey.app/u/Joka)\
**Post date:** [July 29, 2022, 7:03am UTC](https://community.homey.app/t/check-if-a-logic-variable-is-is-not-null/66651/3 "2022-07-29T07:03:11Z")

</div>

In my case a homescript returns ‘’, so the tag is empty (of course I could return something else).

And yes, your answer is the reason for my question 😉

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [July 29, 2022, 11:38am UTC](https://community.homey.app/t/check-if-a-logic-variable-is-is-not-null/66651/4 "2022-07-29T11:38:35Z")

</div>

Null is hard, but setting it to an Empty string (“”) is very easy, because an empty string validates correctly when setting capabilities or tokens.

Answer:

- Create a text variable (set it with a space).
- run a homeyscript with return “” (just 2 double quotes)
- place the HS token in the variable.

Now you have an Empty text variable which you can use to see if a text-token or whatever is also empty.

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [July 29, 2022, 11:40am UTC](https://community.homey.app/t/check-if-a-logic-variable-is-is-not-null/66651/5 "2022-07-29T11:40:38Z")

</div>

![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/2/929143e6c570804e12d1d8fdca73c61f90415981.png)

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [July 29, 2022, 11:41am UTC](https://community.homey.app/t/check-if-a-logic-variable-is-is-not-null/66651/6 "2022-07-29T11:41:39Z")

</div>

As far as i know there is no way to set a capability/token-value to null.

---

<div class="post-metadata">

**Author:** ![Joka](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Joka](https://community.homey.app/u/Joka)\
**Post date:** [July 29, 2022, 6:18pm UTC](https://community.homey.app/t/check-if-a-logic-variable-is-is-not-null/66651/7 "2022-07-29T18:18:26Z")

</div>

You and @FKey are right.

It is even not possible to return null in a token with homeyscript or use it as a variable value out of the box.

Your advise works fine. And with the new inline homescripit it is not even necessary to use a global variable. Just for fun:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/a/1ac1ea7ce13416da5758a52d359dbca99d647343.png)

THX

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [July 29, 2022, 6:51pm UTC](https://community.homey.app/t/check-if-a-logic-variable-is-is-not-null/66651/8 "2022-07-29T18:51:47Z")

</div>

Indeed, the global variable is handy tho, if you check it much: you just reference the existing gloval variable called Empty 😉  
Saves flowcards 😉

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [July 29, 2022, 6:53pm UTC](https://community.homey.app/t/check-if-a-logic-variable-is-is-not-null/66651/9 "2022-07-29T18:53:41Z")

</div>

Also, reading Result equals Empty is imho somewhat nicer then Result equals Result.

---

<div class="post-metadata">

**Author:** ![Joka](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Joka](https://community.homey.app/u/Joka)\
**Post date:** [July 29, 2022, 7:06pm UTC](https://community.homey.app/t/check-if-a-logic-variable-is-is-not-null/66651/10 "2022-07-29T19:06:56Z")

</div>

I agree!

Nice weekend
