Variable confusion

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:

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
(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

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

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

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

That explains this also

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