Help with flow order

I have created a flow that daily calculates the average of my solar production of the last five days. The flow does not react how I suspected. The variablew for the day, after the flow has run, are all the same… It looks like the cards are started all together instead of in sequence.

What am I doing wrong ? I cannot wrap my head around it..

In the above screenshot there was an error withe the day1 variable, that is not the issue I am having, just noticed it and fixed it though. This was the result of me changing an app but not the reason for all variables beiing the same which is what is my issue at the moment.

Flow cards are executed asynchronously, so you will need to add a delay to each one to ensure they run one after the other. E.g. use a 2 second delay on the second card, a 4 second delay on the third card, etc.

Alternatively you could use the Advanced Flow and string the cards together in a chain.

2 Likes

You taught me something ! I did not know cards werr asynchronous…

This way I can solve it, thanks !

2 Likes

Not fixed unfortunately… I added delays but the result is still the same…

What can be wrong ?

You should set day 5 to day 4 after 5 secs
Set day 4 to day 3 after 10 secs
Day 3 to day 2
Day 2 to day 1
Calculate day 1

Serious ?

If I set day 5 to day 4 after 5 seconds

And then 5 seconds after that day 4 to day 3

Then day 4 and day 3 wpuld be the same right ?

The way I read this, this would result in what I ecperience as a fault right now ?

Seriously.

The new day 5 becomes the old day 4.
The new day 4 becomes the old day 3.
The new day 3 becomes the old day 2
The new day 2 becomes the old day 1
The new day 1 is calculated.
In this order with a little delay between each step.

You are setting day 4 to day 5. So day 5 and day 4 have the same value. Then you are setting day 3 to day 4. Now day 3, 4 and 5 have the same value

Je hebt helemaal gelijk.. idioot dat ik dat zelf niet zag.. dank !

No worries.

I didn’t notice this flaw in your first post. So maybe you don’t need a delay between the steps after all.

@Marc_Jurriens you always have to start updating the oldest value first so you can create for new value :slight_smile: i do have similar scenario where i store average daily temperature value from my outside sensor, and i am keeping the values for 3 days and based on that calculate if “heating season” should be enabled of disabled… in advanced flow it looks like this:


replace oldest (D-2) value with one younger (D-1), wait, replace D-1 with D, once this is done new value is calculated and stored in D :slight_smile:

It is working now.. stupid logic mistake..

I prefer to use regular flows, i have a few advanced flows and the technics of them work fine bur i prefer having several simple flows that interact using variables instead of everything in one advanced flow, for me that is more flexible…

I am doing this to steer my energy usage and contract:

1 flow to check if energy prices go negative and set a variable if so

1 flow to take actions based on that variable (stop solar production, set home battery to charge only, turn on all the lights.

1 flow to check if energy prices are going to be negative in 2 hours, if the home battery is full enough then stop solar production and use the home battery untill the negative prices start to drain the battery before it starts charging against negative prices.

1 flow to on a daily basis check what the average production of my solar was and based on that change the battery strategy from solar only ((NOM) to solar+net (ECO).

That way all flows arr small and easy to follow.

Hi Marc, would you mind sharing your new (correct) flow? I’m a bit of a noob when it comes to Homey, but I really like the look of your flow.

Sure:

First flow is used to check if prices are negative to set a variable (I use this to make sure if the app I use to define if prices are negative ever changes I only habe to change this flow and everything else does not need to change):

The next flow then takes action (stop solar production, set batteries to only charge and not discharge, and turn on all the lights):


Then I have another flow that does the opposite when prices become positive again.

I also have a flow that, when prices go negative two hours from now, already turns of solar production to drain the home battery so it can charge the moment prices become negative.