Another variable for a flow in a script question

I am new and try to learn this. :slight_smile: 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.

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

Example is available in Homeyscript:

Where to find them to use in flows:

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


What is wrong in this script?


I have also tried this, but still the response in the flow is the same

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

You have to declare variables I think

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):


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

Thanks. I think it’s good now.

1 Like