# Variable confusion

**URL:** <https://community.homey.app/t/variable-confusion/90369>\
**Category:** Flows\
**Tags:** homeyscript, homey-pro, advancedflow\
**Created:** [September 27, 2023, 11:44am UTC](https://community.homey.app/t/variable-confusion/90369 "2023-09-27T11:44:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrPilloft](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mrpilloft/32/87781_2.png) [@mrPilloft](https://community.homey.app/u/mrPilloft)\
**Post date:** [September 27, 2023, 11:44am UTC](https://community.homey.app/t/variable-confusion/90369/1 "2023-09-27T11:44:52Z")

</div>

I want to find the min/max temperature during the day.

I have a weather station that fires an event when temperature changes. I can’t find the temperature in a “then” flow card, but I have it in the “when” card and can pass it on to a script for instance. Here’s my current flow:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/6/06bf4fd1b53c73d442fdc8a2724b773243501a0c.png)

I’ve created global variables in a script. Logically it’s easy to test for passed value being \>/\< than the variables, but I have several difficulties. Here’s my current script:  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/0/40a5a6e7222334c19cbf4797b02853a21d7d26ca.png)  
(the typo on tempMax should be tempMin has been fixed, but doesn’t change anything)

I would like some help on the following:

1. Why woun’t my script save the temp passed to it when it’s \>/\< then the values in the global variables?

2. I also have “Variables” created in the flow view with the same name as the global variable. Tests reveals that these are not the same instances of variables, so I can’t read the new say Max temperature when control is passed back from the script to the flow again. a) why aren’t these variables shared? b) how can I create variables that can be used in both Flows and scripts?

Thanks…

BTW I init the script variables by running  
`global.set('tempMax', -99); global.set('tempMin', 99); //init values`

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [September 27, 2023, 12:35pm UTC](https://community.homey.app/t/variable-confusion/90369/2 "2023-09-27T12:35:39Z")

</div>

`arga[0].Value` doesn’t exist so that part of the code will never fire, it is only `args[0]`.

---

<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:** [September 27, 2023, 1:01pm UTC](https://community.homey.app/t/variable-confusion/90369/3 "2023-09-27T13:01:43Z")

</div>

> [@mrPilloft](#):
>
> I can’t find the temperature in a “then” flow card

It’s there. When you hit the tag icon, you’ll see a listing with the local tags (provided by the triggercard), and below that the tags of all the devices, just enter the device name in the search bar, or scroll down

 ![Screenshot_20230927-145853_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/0/406ca0fb5f192056b16b4bc5161cbb21fe725cbe.jpeg)

Btw you’ll also find Logic- & Better logic vars, Homeyscript tags

That explains this also

> [@mrPilloft](#):
>
> I also have “Variables” created in the flow view with the same name as the global variable. Tests reveals that these are not the same instances of variables

When you want to create / use “real” Logics variables (instead of homeyscript tags), you can do that also in HS

> [@DIY circadian rhythm based lighting](https://community.homey.app/t/diy-circadian-rhythm-based-lighting/33348/37):
>
> It should be something like this with Logics variables. (First create the variables, and then go [find the variable ID’s](https://community.homey.app/t/diy-circadian-rhythm-based-lighting/33348/36) ) // This is not needed anylonger, so comment out or remove //let BLApp = await Homey.apps.getApp({ id: 'net.i-dev.betterlogic' }); //BLApp.apiPut(`${VARIABLE_PREFIX}temperature/${temperature}`); await Homey.logic.updateVariable({id: '1a164078-63fc-470c-ac76-9da7f113445e', variable: { value: temperature } }) // The example ID should be the ID from var '${VARIABLE\_PREFIX}\_tem…

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [January 14, 2024, 5:19pm UTC](https://community.homey.app/t/variable-confusion/90369/4 "2024-01-14T17:19:30Z")

</div>

![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/3/b/3b9d74080e05fb4d183fb5ef65d29a27d4c8f99d.png)
