Homey Community Forum

Getting Started - Logic variables

Thank you @Peter_Kawa . I will take a look at both options.
Maybe I can see if there is some strange thing going on.
Today I had the same graph with the same lines of use of energy.
I hope I can find it. If is normal us it is ok, but at that time we are in bed.

1 Like

I already managed to create some flows (f.e. average humidity in two rooms), the logic behind the Trends cards was not immediatly clear to me. I thought Trends needed to monitor values for the set duration, but I now understand it just takes it’s data from insights (which is kinda logic of course :wink: ) so the wanted values is immedialty available as soon as you use one of these cards
Tnx for the tip, it does exactly what I need. Trends calculated values are not directly available in Homey Logic to use in other flows but you can assign them to Logic variables in a flow similar to your second.

edit: what I don’t get is how you would use the Trend card in the THEN part of a flow. so, IF thisflowstarted … AND…THEN “calculate Trend something” but you can’t do anything with what you calculate after that moment? Like when you start a flow with a Calculate Trend you have that available as a tag, but not when you calculate in the THEN section of the flow

Ah wait, I do know (because I used them in my own testflows :smile: ) when you “THEN calculate Trend” you can use that calculation as a trigger. In your example: you don’t need to trigger the second flow using “Start Flow” in your first flow, it will be triggered on the “IF calculated” in your second flow

So it would be f.e.

  • IF every 5 min THEN calculate Trend temperature
  • IF Trend Calculated Temperature AND < 20 THEN push “temp too low”

You also could have the first flow calculated more than 1 values, then you can use these as triggers in other flows

Flow 1 calculate all trends:

  • IF every 5 min THEN calculate Trend temperature, calculate Trend Humidity, calculate Trend Luminosity

Flow 2 do something with temp

  • IF trend calculated Temperature AND …THEN send push

Flow 3 do something with hum

  • IF trend calculated Humidity AND …THEN put in Logic variable

When you use calulate Trend in the AND section you can’t use the outcome in the THEN
f.e. IF trigger AND calculate Trend average > 0 then set Var to Average
Outcome is not available as a tag, which might be a shame.

edit: woops…app-author has a fight with Athom

I am building a ArrayAdapter for this precicly in HOOP.

Sounds good @Arie_J_Godschalk, but what is HOOP?

@zakraket Glad 2 hear you discovered the magic yourself.
I also didn’t get it at first🙃, but the THEN action card explains what do do

And how nice! The new testversion let’s you also calc trends live! No flows needed. Handy for troubleshooting

Tag “Average” value:

Here r my 2 example flows:

As u can see, you can use calculated tag(s) for further use.
Or did you mean someting else to re-use the tagvalue with:

{“When you use calulate Trend in the AND section you can’t use the outcome in the THEN
f.e. IF trigger AND calculate Trend average > 0 then set Var to Average
Outcome is not available as a tag, which might be a shame.”}

H.O.O.P. (Hope) - Homey Object Oriented Programming - Apps - Homey Community Forum (athom.com)

1 Like

Yes, I’ve been playing with it for a few things now.

I have one flow that calculates several trends
IF every minute
calculate trend temperature
calculate trend humidity
calculate trend sunpower (from solarpanels)

Now I can create separate flows for each calculated trigger
IF temperature trend calculated THEN f.e. put in var (for later use)
IF humidity trend calculated AND value<x THEN f.e. push to user

But I think the use of
IF trigger AND calculated Trend < value THEN something
is limiting since the AND calculated trend is not available later on. It would be better if it was put into a tag (but maybe that’s just too difficult to build or whatever)

At least I now have real trendvalues to work with instead of values that go up and down and are not suitable for proper decisions.

In your example you don’t need the Start Flow 2 in flow 1 :slight_smile:

1 Like

So nice to hear this works for you!

I’ve created a logic NUM var:

With this flow I store the calculated value to the ‘Insights_Average_Saved’ var:

Outputted values:

Edit I see now​:laughing: Flow 2 gets triggered when the calculation has finished. Didn’t get that at first :upside_down_face:
(Orig: While I’m just testing, it seemed handy for me to start flow 2 with flow 1, and then get my calculated value as in “real life”)

Very very interesting Arie. I never got it why flows can’t be set up Macrodroid-wise, but u r going the right direction with H.O.O.P.

Thanks, almost ready for release to HCS. Its been tested and fixed, and allready has more then i currently have written on the topics.

1 Like

yes, but it requires an extra flow. I have also set it up this way. But never mind, at least it works!

Btw what’s this screenshot? Is this the app? I don’t have this

As I wrote: The new testversion (of the app) let’s you also calc trends live, no flows needed. Handy for troubleshooting.
Go to More>Apps>Insights Trends and hit “Configure app”
Link to testversion:

Sorry, missed this between the screenshots , tnx

I wasn’t gonna call you names, yet :wink: :wink: :wink:

How did you figure out the day in order to put the day name in a variable?

I’m not sure to what you’re referring to. Can you quote that pls?

How did you calculate which day it is in order to put the name of the day in that text variable?

While I was curious, and like to find out things, I came up with this.
It should run until Homey dies.
Maybe I missed something, or things can be done in other ways, pls let me know!

How to display (or to use with speech) name of today and this month

A. Create 2 variables, type Text

  1. NaamVanDag (name of day), no text need to be entered.
  2. NaamVanMaand (name of month) & enter the name of the current Month

B. Create 7 flows, one for each weekday



And so forth

C. Create 12 flows, one for each month



And so forth

some/most can be done in HomeyScript:


let SysInfo = await Homey.system.getInfo();
var weekDay   = SysInfo.dateHuman.slice(0,(SysInfo.dateHuman.indexOf(' ')));
await tag("WeekDay", weekDay );       //creating new HomeyScriptTag 'WeekDay'
console.log("Weekdag", weekDay);
1 Like

Thanks! I don’t have enough knowledge to write a script like that.
Most of the time I can read what a script should do.
So if I’m correct this script creates tag named Weekday and then this script updates the value of it with the name of the weekday.
Does it create the same tag each day? Or is this skipped if it already exists?

But, well, this saves a lot of flows :wink: :wink: