# Another variable for a flow in a script question

**URL:** <https://community.homey.app/t/another-variable-for-a-flow-in-a-script-question/119752>\
**Category:** Questions & Help\
**Tags:** flow\
**Created:** [November 4, 2024, 1:54pm UTC](https://community.homey.app/t/another-variable-for-a-flow-in-a-script-question/119752 "2024-11-04T13:54:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bjarand](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bjarand/32/103865_2.png) [@Bjarand](https://community.homey.app/u/Bjarand)\
**Post date:** [November 4, 2024, 1:54pm UTC](https://community.homey.app/t/another-variable-for-a-flow-in-a-script-question/119752/1 "2024-11-04T13:54:59Z")

</div>

I am new and try to learn this. 🙂 The examples I have seen this far do not make me understand how to make a tag or variable usable for flows. I have made scripts for tags and variables and they seems to be succesful, but the boolean variable to use in flows don’t change like I want to.

I have a script, something like this:

Today = (Math.floor(new Date()/86400000)%42);  
if (Today == 40) { Clean = true; }  
else { Clean = false;}

I want to use “Clean” as a variable in a flow

When: 05:00AM  
Then: Run script  
And: Clean = true  
Then: Send message to me

This is an example, but the main question is how I can use a boolean from the script in a flow.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [November 4, 2024, 7:36pm UTC](https://community.homey.app/t/another-variable-for-a-flow-in-a-script-question/119752/2 "2024-11-04T19:36:15Z")

</div>

You can create a tag, which is available for flowcards.

Example is available in Homeyscript:

> ![1000037291](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/e/6e7e71096832ac600244c9837151b300da0e4084.jpeg)

Where to find them to use in flows:

> ![1000037293](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/0/8005109452b80d6a90132b22df5b47091f5d972c.jpeg)

---

<div class="post-metadata">

**Author:** ![Bjarand](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bjarand/32/103865_2.png) [@Bjarand](https://community.homey.app/u/Bjarand)\
**Post date:** [November 4, 2024, 10:36pm UTC](https://community.homey.app/t/another-variable-for-a-flow-in-a-script-question/119752/3 "2024-11-04T22:36:54Z")

</div>

Thanks. I have tried the tags function, but I believe I didn’t understand how to use it.

 ![Skjermbilde 2024-11-04 232955](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/e/0e2eb64a3143a44154683ae3d9d46a1d0c7aa611.png)  
What is wrong in this script?

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/7/a74f11989a066c85de5f9f6ccbf49552445191f2.png)  
I have also tried this, but still the response in the flow is the same

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/7/97329777f3eee6c291203d2d9e708bc0a871ec85.png)

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [November 4, 2024, 11:00pm UTC](https://community.homey.app/t/another-variable-for-a-flow-in-a-script-question/119752/4 "2024-11-04T23:00:01Z")

</div>

The issue is not the tag, in the first screenshot tag usage is OK

You have to declare variables I think

```auto
const toDay = (Math.floor(new Date()/86400000)%42);
let cLean = false;
if (toDay === 40) { 
  await tag('Clean', true)
}
else {
  await tag('Clean', false)
};

log('toDay = ', toDay);

```

Because `toDay` is 39, the tag called Clean is No (false):

> ![afbeelding](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/0/60b7d1ad2b38898321d6979b3eefc0641f57a1b5.png)

A comment to the flow: Add the “Clean” tag as well to your push message. Then you’ll be able to check what its value is, and if it makes sense.

\_  
And please copy/paste the script as text. Then we can paste it as script to test with it. Please use preformatted text

> ![Screenshot from 2024-11-05 00-04-55](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/d/5d496698fdb283f2c99289fe7af7ad0ceb46f10d.png)

---

<div class="post-metadata">

**Author:** ![Bjarand](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bjarand/32/103865_2.png) [@Bjarand](https://community.homey.app/u/Bjarand)\
**Post date:** [November 5, 2024, 4:59am UTC](https://community.homey.app/t/another-variable-for-a-flow-in-a-script-question/119752/6 "2024-11-05T04:59:12Z")

</div>

Thanks. I think it’s good now.
