Rule with average

See Design Pattern: Separation of Behaviors, in particular the “Store Result” section of the “Concept 1: Item” section.

I use that template and it seems to work well enough. Of course it’s only going to be as good as the inputs into the rule in the first place. If the cloudiness reading from your weather binding only updates once per hour or isn’t particularly accurate for your location then the rule isn’t going to accurately reflect the current amount of sunlight.

When you use the private cache, the values stored are only available in the script that put the value into it. With the shared cache, any script, even a script from another rule, can access and modify the variable stored in the cache. The shared cache is a place to store values you want to share across scripts.

Note that to share a value between a script condition and script action in the same rule you still must use the shared cache. The private cache is private to the script, not the whole rule.

You don’t have a remainder when you multiply though. You only have a remainder when you divide. Given the first operand is 7 and the second operand (the one after the divide symbol) is 3, the remainder would be 1. 7 / 3 = 2 remainder 1.

Yes but be careful in your variable names in that case so you don’t accidentally overwrite a variable in another rule that is using the cache for something else.

Overall, the cache approach is a good one but I prefer the Item approach mainly because the state of an Item can be used outside of scripts. You can put the average windspeed on your sitemap or MainUI for visualization, chart the average over time, and use it in simple “Item Conditions” or triggers on your rule.

If you apply Separation of Behaviors, the cron rule will just calculate the windspeed average and update the Windspeed_Average Item. Then you could move the code that raises and lowers the blinds to another rule that triggers on changes to Windspeed_Average. In simple cases you don’t even need to write code, you can add a condition and issue a command to another Item without even needing any Blockly code at all.