How to get the highest value from different apps

Hi

I use 3 weather apps.
All 3 show different values and all 3 have totally inaccurate values on some days for wind guts.

I want homey to check the wind gust values for each app and then use the highest value.

I have no clue on how to do that.

Hope someone can help.

In short test first 2 values who is greater and then testing that to the last value.
You may used >= for clarity but if 2 are equal then the result is the same.

Value 1 = 3
Value 2 = 8
Value 3 = 7
                                        yes .. Result = Value 1
                 yes .. Value 1> Value 3
                                         no .. Result = Value 3
Value 1 > Value 2
                                        yes .. Result = Value 2
                  no .. Value 2> Value 3
                                         no .. Result = Value 3

  1. No
  2. Yes
    Result = 8

Thanks theo

I get the idea … now i need to get this in an advanced flow

Thanks for the inspiration :+1:

Have you found a solution for your question? :wink:

Did not have much time so far :person_shrugging:

Because I know now that you use advanced flow I found it a nice test for myself.

Var 1 - Var 3 are your wind guts values.
Variable Result get the highest of those 3.

Look to the place of Var 3 in the tests .
This way you have only 3 end carts needed.

If you don’t mind using the HomeyScript app, then that’s a relatively easy solution too, and is infinitely expandable, not just 2 or 3 tokens, just separate the tokens with a semicolon (;).

Card used:
Run [code] with [argument] and return Number-tag
screenie

Code used:

// Max()
const values = args[0].split(';').map(str => Number(str));
return Math.max(...values);

Or if you rather don’t want to use another app, you can also save the maximum value in a logic variable first and trigger the rest of your flow on that change:

Card used:
Calculate [variable] as [text]
screenie2

Calculation used:
{{ max([wind1], [wind2], [wind3]) }}

2 Likes