# Not able to access tag set in HomeyScript in advanced flow

**URL:** <https://community.homey.app/t/not-able-to-access-tag-set-in-homeyscript-in-advanced-flow/120908>\
**Category:** Questions & Help\
**Tags:** homeyscript, advancedflow\
**Created:** [November 18, 2024, 7:43pm UTC](https://community.homey.app/t/not-able-to-access-tag-set-in-homeyscript-in-advanced-flow/120908 "2024-11-18T19:43:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aesubs](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/aesubs/32/113989_2.png) [@aesubs](https://community.homey.app/u/aesubs)\
**Post date:** [November 18, 2024, 7:43pm UTC](https://community.homey.app/t/not-able-to-access-tag-set-in-homeyscript-in-advanced-flow/120908/1 "2024-11-18T19:43:15Z")

</div>

Hello Folks,  
I was hoping to get some help here. I have a homey script that returns a large json object and attempts to set a tag for it. The return value looks perfect. And indeed the tag appears under the API endpoint when I request flowTokens via http. However, the Advanced Flow doesnt even show it as an available tag. Anyone know what I might be doing incorrectly?

homeyscript:

```auto
## other functions
...

async function main() {
    const zones = await Homey.zones.getZones();
    const devices = await Homey.devices.getDevices();

    const sensors = await getClimateValues(zones, devices);
    const thermostats = await getThermostats(zones, devices);

    const result = { thermostats, sensors };

    console.log("generated json result tag")
    tag('climate_value_all', result);
    return result;
}

return await main();

```

http response from API:

 ![Screenshot 2024-11-18 at 2.43.54 PM](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/0/40dcd7e602d5b88ef0cb4f2a64b61cab860c3e22.png)

Flow only shows a placeholder value called “My Number” under “HomeyScripts”

 ![Screenshot 2024-11-18 at 2.44.39 PM](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/2/525d5f3195583f4089febe2ecad0742e6bee490b.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 18, 2024, 8:05pm UTC](https://community.homey.app/t/not-able-to-access-tag-set-in-homeyscript-in-advanced-flow/120908/2 "2024-11-18T20:05:22Z")

</div>

Hi Andy,

The tag is not getting any data, while you need to use `await` AND a string value needs to have quotes around it, as opposite to num & bool values:

- String:

```auto
await tag('My String', 'abcdef');

```

- Numeric:

```auto
await tag('My Number', 123);

```

- Bool

```auto
await tag('My Boolean', true);

```

While you use a _const_ as string value, you can force it by using  
`String(result)`  
Like this:

```auto
await tag('My String', String(result));

```

---

<div class="post-metadata">

**Author:** ![aesubs](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/aesubs/32/113989_2.png) [@aesubs](https://community.homey.app/u/aesubs)\
**Post date:** [November 18, 2024, 8:18pm UTC](https://community.homey.app/t/not-able-to-access-tag-set-in-homeyscript-in-advanced-flow/120908/3 "2024-11-18T20:18:27Z")

</div>

Thanks for the reply @Peter_Kawa ,

Is this how I should be casting my json object?

```auto
async function main() {
    const zones = await Homey.zones.getZones();
    const devices = await Homey.devices.getDevices();

    const sensors = await getClimateValues(zones, devices);
    const thermostats = await getThermostats(zones, devices);

    const result = { thermostats, sensors };

    console.log("generated json result tag")
    await tag('climate_value_all', String(result));
    await tag('climate_value_all_test', 'test_val');
    return result;
}

return await main();

```

I just tried it and neither climate\_value\_all nor climate\_value\_all\_test appear in the advanced flow. Any Ideas?

---

<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 18, 2024, 8:24pm UTC](https://community.homey.app/t/not-able-to-access-tag-set-in-homeyscript-in-advanced-flow/120908/4 "2024-11-18T20:24:42Z")

</div>

Ah wait, I didn’t notice they’re inside a function 😬  
Try without the `await`

---

<div class="post-metadata">

**Author:** ![aesubs](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/aesubs/32/113989_2.png) [@aesubs](https://community.homey.app/u/aesubs)\
**Post date:** [November 18, 2024, 8:38pm UTC](https://community.homey.app/t/not-able-to-access-tag-set-in-homeyscript-in-advanced-flow/120908/5 "2024-11-18T20:38:11Z")

</div>

no change without the awaits, im afraid.

---

<div class="post-metadata">

**Author:** ![aesubs](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/aesubs/32/113989_2.png) [@aesubs](https://community.homey.app/u/aesubs)\
**Post date:** [November 18, 2024, 8:43pm UTC](https://community.homey.app/t/not-able-to-access-tag-set-in-homeyscript-in-advanced-flow/120908/6 "2024-11-18T20:43:58Z")

</div>

interestingly they do appear when use “run code” and return as text. then it allows me to see the tags in another step, but not when I use the “run script”

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/5/0587bb8cb38388cba271d946b5345685432d9071.png)

---

<div class="post-metadata">

**Author:** ![aesubs](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/aesubs/32/113989_2.png) [@aesubs](https://community.homey.app/u/aesubs)\
**Post date:** [November 18, 2024, 9:40pm UTC](https://community.homey.app/t/not-able-to-access-tag-set-in-homeyscript-in-advanced-flow/120908/7 "2024-11-18T21:40:12Z")

</div>

In the case that the data was too large I also tried the following with no visible option to search for tag in the “number” logic evaluation

```auto
async function fetchall() {
    const zones = await Homey.zones.getZones();
    const devices = await Homey.devices.getDevices();

    const sensors = await getClimateValues(zones, devices);
    const thermostats = await getThermostats(zones, devices);

    const data = { thermostats, sensors };

    return data;
}
const all_climate = await fetchall();
const sleeping_zone_agg_f = all_climate.sensors.home.zones.inside.zones.upstairs.zones.sleeping.aggregate.avgTempF;
const living_thermostat_targetTempF = all_climate.thermostats.living_thermostat.targetTempF;
await tag('sensors.home.zones.inside.zones.upstairs.zones.sleeping.aggregate.avgTempF', sleeping_zone_agg_f);
await tag('thermostats.living_thermostat.targetTempF', living_thermostat_targetTempF);

return {sleeping_zone_agg_f, living_thermostat_targetTempF}

```

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/1/b134aa3215cc2c6bbb3a5a62c8fa3f3f8bc8a12e.png)  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/0/80b3b71655fed4782608989485c3eceb8d19a8a3.png)
