# Can running a script from a card create a tag?

**URL:** <https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565>\
**Category:** Questions & Help\
**Tags:** homey-pro\
**Created:** [May 9, 2024, 5:53am UTC](https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565 "2024-05-09T05:53:09Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Picante](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/picante/32/79541_2.png) [@Picante](https://community.homey.app/u/Picante)\
**Post date:** [May 9, 2024, 5:53am UTC](https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565/1 "2024-05-09T05:53:09Z")

</div>

Hi, I am trying to find a way to have a two way interaction from a flow card to a script and back.  
I have tried the following card, but I am not able to get a tag created, based on the “No tags have been generated” comment, I am assuming that this card allows to get data back to the flow.  
HomeyScript, Run with argument   
Please let me know if you know what I might be doing wrong or perhaps other suggestions, I will also add the sample code for the script.  
Thanks in advance.

 ![Card](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/7/879474f02e093ea358d7399563caeb749a2481c2.png)  
 ![script](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/e/5ee99a05d35d1714d02ac9b5d250e13a98cac065.png)

---

<div class="post-metadata">

**Author:** ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)\
**Post date:** [May 9, 2024, 8:22am UTC](https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565/2 "2024-05-09T08:22:47Z")

</div>

See example-tag.js and use single quotes.

When you want to use the tag in a flow (with a logic card) it can be found under Homeyscript.tag.

---

<div class="post-metadata">

**Author:** ![Picante](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/picante/32/79541_2.png) [@Picante](https://community.homey.app/u/Picante)\
**Post date:** [May 9, 2024, 8:47am UTC](https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565/3 "2024-05-09T08:47:59Z")

</div>

> [@Rmb](#):
>
> When you want to use the tag in a flow (with a logic card) it can be found under Homeyscript.tag.

Thank you, I’ll give that a try

---

<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:** [May 9, 2024, 5:28pm UTC](https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565/4 "2024-05-09T17:28:46Z")

</div>

It’s also possible to use the script as code in a HS flowcard like  
Run `your_code` with `argument` and return [type]-tag

 ![Screenshot_20240509-191821_Firefox](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/7/279ab8cc4194ed8040830760c1f6979924cd295f.jpeg)

You can use your HS tag as argument, and have your script update that tag’s value

 ![Screenshot_20240509-191529_Firefox](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/2/522e89eac0eaefa7fede05775aa0a9524be6411d.jpeg)

 ![Screenshot_20240509-191643_Firefox](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/c/5c603a6935bf501b4c4a8c93367068b6cfbf00b6.jpeg)

---

<div class="post-metadata">

**Author:** ![Picante](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/picante/32/79541_2.png) [@Picante](https://community.homey.app/u/Picante)\
**Post date:** [May 10, 2024, 9:08am UTC](https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565/5 "2024-05-10T09:08:13Z")

</div>

> [@Peter\_Kawa](#):
>
> `your_code`

Thank you. Would you be able to show how in your code you return the tag and how you use it on another card?  
In your code do you create a tag or do you use return ?  
Cheers

---

<div class="post-metadata">

**Author:** ![Picante](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/picante/32/79541_2.png) [@Picante](https://community.homey.app/u/Picante)\
**Post date:** [May 10, 2024, 9:09am UTC](https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565/6 "2024-05-10T09:09:42Z")

</div>

Thank you, from a functionality point of view that worked, I have realised that this might have been working, but I am not sure why the “No tags have been generated” message appears.

---

<div class="post-metadata">

**Author:** ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)\
**Post date:** [May 10, 2024, 2:06pm UTC](https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565/7 "2024-05-10T14:06:41Z")

</div>

I am lost. What did you try and what is your current problem. Did you noticed that Peter uses another card?  
Maybe it is not an error message but an informational message, as there are two similar cards, one creating a tag and the other not.

---

<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:** [May 10, 2024, 11:20pm UTC](https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565/8 "2024-05-10T23:20:09Z")

</div>

> [@Picante](#):
>
> Thank you. Would you be able to show how in your code you return the tag and how you use it on another card?  
> In your code do you create a tag or do you use return ?  
> Cheers

Sure. Forgive me if I show things you already know, I just start at the starting point.

First create the desired tag with a one time script:

> ![Screenshot from 2024-05-11 01-04-27](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/1/61f375a2c66ab9cf2733f15c5b54cac74f534acf.png)

This way it shows the script output, and the tag value of ‘My\_String’:

> ![Screenshot from 2024-05-11 01-04-46](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/5/55682d598c90caf319bb187f165b83f01fb6c205.png)

> ![Screenshot from 2024-05-11 01-05-04](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/2/521eb547463c6e8942d953a77b86abb85ec127e1.png)

How to find and insert the HS tag ‘My\_String’:  
 ![Screenshot from 2024-05-11 01-21-43](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/0/70bd669cacc14cc3ac6c2b79bab776f009ebbed8.png)

Now I can change the ‘My\_String’ value with this “Then” action flowcard:

> ![Screenshot from 2024-05-11 01-13-41](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/3/53651cf06350dc6aa748926350344039f0e4fad8.png)

As example: when the input argument changes, the tag value changes:

 ![Screenshot from 2024-05-11 00-53-32](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/0/e0668a8243e8e415dff47ba4f77a602ff71cf2d0.png)

The code I used in that flowcard:

```auto
// update homeyscript tag, dependent on input argument's value

// save the input argument to a script var
const myArgument = (args[0]);
// for testing only: comment line above, uncomment line below
//const myArgument = 'hello Picante';

// When the argument value was as expected
if (myArgument == 'just_a_new_value') { 

  // write new value to tag My_String
  await tag('My_String', 'hello Picante');
  return 'myArgument used: (' + myArgument + '), tag My_String is updated to: hello Picante';

}

// When an other argument value was as expected
if (myArgument == 'hello Picante') { 

  // write new value to tag My_String
  await tag('My_String', 'just_a_new_value');
  return 'myArgument used: (' + myArgument + '), tag My_String is updated to: just_a_new_value';

}

// end

```

---

<div class="post-metadata">

**Author:** ![Picante](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/picante/32/79541_2.png) [@Picante](https://community.homey.app/u/Picante)\
**Post date:** [May 11, 2024, 3:13am UTC](https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565/9 "2024-05-11T03:13:13Z")

</div>

> [@Peter\_Kawa](#):
>
> ```auto
> // When an other argument value was as expected
> 
> ```

That’s awesome, thank you.

---

<div class="post-metadata">

**Author:** ![Picante](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/picante/32/79541_2.png) [@Picante](https://community.homey.app/u/Picante)\
**Post date:** [May 11, 2024, 3:14am UTC](https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565/10 "2024-05-11T03:14:04Z")

</div>

Thank you both for taking the time to reply.

---

<div class="post-metadata">

**Author:** ![Picante](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/picante/32/79541_2.png) [@Picante](https://community.homey.app/u/Picante)\
**Post date:** [May 11, 2024, 4:19am UTC](https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565/11 "2024-05-11T04:19:20Z")

</div>

**My learnings summary:**  
if this helps anyone (Thanks @Peter_Kawa & @Rmb, please let me know if you think any of this is not accurate ):

- How do you create a script and return a value to be used on another card?
  - I will be using the following method, there are pros & cons for different approaches, because I believe is creates less of a management overhead in some areas and it means that I do not need to create and maintain a Tag, this one only needs to be used locally. The following also appears to show me the returned value for the script on the card when I run it from the flows screen, I was not able to get this working another way.

**Method:**

1. Add a card of under HomeyScript of type “Run ` with and return <Number_Yes/No_Text-tag>” The type depend on the data type value that you expect your script to return.`

`

Add your script to the card, and include a return value, my example is simply returning the value that I send in as an Argument, in my example is “Gracias Amigos!!!”

To fully show showcase the capability. I created a Push notification card (purely for testing).

Create a connector from the Script card to another card where you want to use the output of the script. (It is CRITICAL, that you add a connector or you will not be able to see the Result tag.)

In the card that you linked the script to (where you want to use the script’s output, select the Tag from the “This Flow” section. )

If you’d like to see the result, run the flow (using the play button), then mouse over the blue line on the bottom of the script card to see the result.

`
`
Screenshots:

(no need to show this, easy)

(no need to show how to create this, but showing the difference if a connector is present or not, showing that one will allow the selection of the Tag and without the link the Tag will not be available)

(no need to show again, shown above )

Show the result value on the card.

`

---

<div class="post-metadata">

**Author:** ![Antohagg](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/antohagg/32/48013_2.png) [@Antohagg](https://community.homey.app/u/Antohagg)\
**Post date:** [December 6, 2025, 7:48pm UTC](https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565/12 "2025-12-06T19:48:38Z")

</div>

I cant see these return cards, is it only for advanced 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:** [December 6, 2025, 8:09pm UTC](https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565/13 "2025-12-06T20:09:21Z")

</div>

Correct.  
Standard flow miss the possibility to use tags provided by action cards.

But it sure is possible to get the script result in standard flow;  
you can call pre-saved scripts, in both Homeyscropt AND cards\[1\] and THEN cards, and with these scripts you can create Homeyscript tags, which you can insert in your flow cards.  
So, same result, but with a bit of a D-tour

¹) main advantage of using Homeyscript And cards:

1. the flow will only continue if the script has finished → meaning you won’t have to add a delay to your action card(s)
2. the flow will halt if the script errors

* * *

1. Footnotes
