Trying to set a variable from a script, help needed

I’m trying to set a boolean variable from a script, that should be then used in flows.

I understood that I am supposed to set a tag and not a global variable.

So looking at examples i put:

await tag(‘aria_inquinata’, aria_inquinata);
return("aria inquinata: "+aria_inquinata);

The script returns the value, but the variable is not appearing under “variables” in the app and I can’t use it to trigger a flow. It does appear under the tags that can be selected in the “and” part.
If I create a variable with the same name in the app, it doesn’t change value running the script.

So global variables, tags, and app variables are 3 different things? How can I write an app variable from a script? I there any comprehesive guide I can read?


You can find HomeyScript variables, when you make a flow and add a tag, scroll down untill HomeySctipt variables, like you do for device variables.

Yes thanks, but it doesn’t show up in the “variables” section of the Homey app, right? Is it possible to modify those variables in a script?

If it is not a boolean or numeric value, the var should be quoted
As shown in the example scripts:

Yours should be adjusted it to:

await tag('aria_inquinata', '"' + aria_inquinata + '"');


await tag('aria_inquinata', `'${aria_inquinata}'`);

That will add literal quotes, which is not what you want. Instead, use this:

await tag('aria_inquinata', String(aria_inquinata));
1 Like

Ah yes I saw that happening, but didn’t know your trick yet :face_with_peeking_eye:

aria_inquinata is a variable in the js script with value true/false (boolean)