Since I have a very well insulated house, the heat inside the house dissipates very difficult once heated up. My aim is to keep the heat out of the house by means of automatically working sunscreens at every window facing the sun. I have been struggling for a long time to get it working properly.
First I tried to determine whether the sun is shining be means of LUX sensors. (Fibaro Multisensor). Apart from the fact that they didn’t work as trustworthy as I hoped, they solely measure sunlight intensity, which is something different than sun warmth. Furthermore the multisensor is not meant to be mounted outside, requiring a protection enclosure, which affected the LUX readings. This also rendered the temperature sensor of the Fibaro Multisensor useless, since it is mounted in direct sunlight inside a box. So I concluded a separate temperature sensor would be required.
While trying to combine the LUX sensor with a Temperature sensor, I came to the idea to simply look at the difference between the temperature of direct sunlight and the ‘standard’ outside temperature (shadow). I found out that this is a trustworthy way to determine whether the sun is shining, and at the same time it provides me with proper temperature data. The Fibaro Binairy sensor I use can handle 4 temperature sensors simultaneously. Currently it measures temperatures of sunlight, shadow (outside temperature), inside living room and cellar.
It all resulted in the following flows:
- One flow calculating the average shadow temperature, using the last 18 raw data readings
- One flow calculating the average sunlight temperature, using the last 18 raw data readings
- One flow calculating the temperature difference and set a Boolean at a certain value
- One flow measuring the shadow temperature and set a Boolean at a certain value
These flows are closing the sunscreens:
- One flow setting above mentioned Boolean TRUE when temperature difference is more than 7ºC
- One flow setting above mentioned Boolean TRUE when shadow temperature reaches 20ºC
- One flow checking if both booleans become TRUE and if so, lower the sunscreens (also depending on the time).
These flows are opening the sunscreens:
- One flow setting above mentioned Boolean FALSE when temperature difference is less than 5ºC
- One flow setting above mentioned Boolean FALSE when shadow temperature is less than 20ºC
- One flow checking if Boolean for temperature difference becomes FALSE and if so, open the sunscreens.
The result as shown in Insights over the course of two days:
If somebody is interested in the actual flows, please let me know here. I could post these too.
Ingenious! Yes, please share the Flows!
Nice! Interested in how you are doing the average temperature flow for the last 18 raw readings… are you storing 18 variables and averaging this? I’m looking at found something similar but more efficiently than having so many flows.
Nice read and very kind of you to share this!
And I too am interested in seeing the used flows.
Thanks for your replies. Below are the flows I use to get it working as it currently does.
The first step is importing the raw data. I have the following flow mainly in order to filter out wrong readings. However they almost never occur anymore since I improved all wire connections to the temperature sensors:
The second step/flow is making an average of the raw temperature readings. This is important for a smooth working of the screens. I don’t want to have the sunscreens jumping up and down with every cloud passing by. So this is particularly important with sunlight temperature. Therefore I am averaging this readings with 18 previous readings. This gives a delay of about 40 minutes. So 40 minutes of consistent sunshine is required to lower the sunscreens:
This is another screenshot where I am averaging with only 6 previous readings:
The third step is taking care of setting the booleans correctly. I have 4 flows to take care of it:
The fourth step is basically checking if all conditions are met and actually close the sunscreens:
The fifth step keeps an eye on the conditions to open the sunscreens:
@Berend nice work!
I would love if BL would have an running average function; that would make your flows much more simple
A simple formula for average calculation of last 10 items is:
the-average = round((((the-average*10) + new-value )/11)*100)/100
( please shoot )
Hmm, I am eager to understand this formula, but I don’t grasp it yet.
What should be in my case filled in the place of ‘the-average’ between the brackets?
the-average should be a numeric variable (better logic f.i.) (TempVentilation?)
I am trying to figure how this formula would work and I created a test flow… without succeeding
It is not clear for me how the 10 previous readings (which then need to be averaged), become part of the calculation.
If I understand correctly:
New-Average = (10*Old-Average + new value) / 11
Since the old average is taken from 10 data points, just give it a weight of 10. Add the newest datapoint (= weight 1) and divide by 11 for the new average.
10 datapoints: (1+2+1+1+1+2+1+1+1+1) / 10 = 1.2 average
New datapoint = 2
New average = (1.2 * 10 + 2) / 11 = 1,27
I think that would be ok, when averaging out an fluctuation around one level; ie the actual value of the 11th measurement point is not that relevant.
For this particular case, where a rising average would need to captured, the value of the 11th measurement point is relevant…
So it will lead to a (slightly) different trigger moment…
As @Sytze already mentioned, the 10 previous readings are already in the variable “old-average” but you don’t need 2 variables (New and Old-average), this can be the same variable called “the-average” or just “average”. Only from the start, the calculated average will rise slowly, from zero to the “middle” value. It is also possible to use only the last 6 points by ((average*6)+new)/7.
Also, @TedTolboom is right, it’s not '100% math right all the time, but for this purpose, I wouldn’t care.
Be aware that if you put this in a mathjs card, there have to be “$” signs before and after the variable name in the left box:
Or drag the tag in there ofc.
I’ve got the formula working and letting Insights create some graphs. I will revert with a screenshot of the actual results of this type of averaging. Thanks for the input so far!
Here is a Insights screenshot showing the actual behaviour of different calculations of averaging. I conclude that the proper/standard formula for calculating the average reflects the movements of the raw data the best. If I want to achieve the same smoothness of the curve by using the ‘new’ formula the lag becomes pretty much. For the purpose of automatic sunscreens a lag of 30-45 minutes seems to be optimal.
So, I will for now implement the new formula and multiply the average by 12 (green curve). Practise needs to proof if the smoothness of the curve is sufficient. I tend to think that the sunscreens will be a bit too actively jumping up and down. However, much easier implementation of the formula is the advantage we are looking for.
By the way: isn’t it unbelievable that we enjoy this kind of weather in October in the Netherlands? Every day more than 20ºC with sunshine:
Thanks for showing! My usecase and the approach is very different.
Before there was domotics, in our previous family house, we had a Somfy wind and sun sensor outside and a switch for sun / wind speed / timerdelay inside. For a sun screen of 7 meters long, with 2.5 meters arm length on the south really a good thing to keep it from sailing away!
Now I have two adjacent roller blinds on the east side of an apartment building and I use Suncalc and the lux measurement of a Sensor6. When a certain angle of entrance is passed, the the “down” response comes fairly quickly after we reach a lux value above Lux_Max_Living room. The signal “up” after some time delay when back under Lux_Min_Living room or a “sunset-x” angle. We had some knowledge exchange on this last year @ Slack.
All this shows that there are opportunities here for a sunscreen maker or an app wizard to create a truly versatile solution.