Homey Community Forum

Advanced roller blinds with light sensor and time based

Dear readers,

We’re using a few flows that are managing our main roller blind in the living room. We life in a older house facing a street with a lot of bicycles and pedestrians that could always easily look into our living room. Besides that, we have the morning sun on our front window that’s heating up the house from sunrise till about noon.

What we’re building
Using multiple variables we are building a flow system that’s rolling our blinds up and down using time and the amount of light that’s coming in. In our case we use one roller blind but you can add as many as you wish.

In our case, we use three heights: 20%, 60% and 100% closed. I think it’s more ‘homey’ (:wink:) when the blinds are not fully open but stay at a 20% height as ‘open’. The 60% is used when there is more light coming OR it’s getting dark outside (lower your blinds a bit) OR it’s getting late in the evening. The 100% closed is used when the sun is very bright and hot soo it keeps the heat out.

What we need, the requirements
In order to build these flows you need a couple of things.

  1. A Homey (ofcourse :wink:)
  2. A roller blind or curtain motor of any kind
  3. A light sensor
  4. A variable ‘Rolgordijn’ (or anything you like) that’s set numeric

In our case we use a TUYA based motor. There are a lot of tube roller blinds that you can build into your system. In our case this wasn’t a option because the tube is very large and we couldn’t find the right motor for this but also our system is build into the wall (don’t know how to explain it) soo we can not make it wider with a build in motor.
This is why I choose for a motor that is rotating the cord of the roller blind. I was a little bit sceptical about this motor but it has been running for about 18 months now and without any problems. I must say that the price went up pretty hard haha, when I bought it I paid 45,00 euro’s and now it’s almost 90,00 euros. However, this is the device that I am using:

For the light sensor I placed a Xiaomi Mijia Light Sensor bought on AliExpress. I find these sensors very stable, they never lost signal and the first battery is still inside and working just fine.

Last, the variable. In previous versions of these flows I sent the calculated height directly to the roller blinds. The problem is that when we came home and the roller blinds were down, it took the system a while before it started calculating and roll them up.
With this variable we are going to do two things; write the new calculated height (even when the whole house is turned off and nobody is home) and read the height when somebody is home or is coming home. This way we always have the right height set.
Ofcourse you have to make sure that the sensor is placed in front of the roller blind / curtain some how soo that it gives the right amount of light even when the blinds are down!

Counting the actions, making sure it’s not going up and down
In the summer there might be a situation that the blinds are going up and down up and down, in order to make sure this isn’t happening I am experimenting with a roller blind counter and a few extra flows. This is still in beta testing soo I am not going to write this all down. Once I am sure this is working fine, I will add a comment below explaining what I did here.

The first flow: calculating the right height
Let’s start building the first flow. First we are going to calculate the right height the roller blind should be in. Please notice that the given amount of LUX might be different in your situation. I suggest you take my numbers first and see what will happen. If this is not giving you the results you’ve wished for, you could change these figures while testing. More about this below!

Oké soo let’s have a look at what I did here. We are going to trigger this flow every 1 minute. The sensor value will update almost live, but this is fine. Once the value is updated the roller blind will move to the desired height and if we do it live the blind may get a new value every X seconds, soo a minute is fine!

In this flow we are first looking at; are we going to put it on an 20% or 60% height?

When the brightness of the light sensor is below 500:
It’s getting dark outside, let’s lower the blinds. We’re not a live television for people walking by :wink:.

When the brightness of the light sensor is above 22000:
There is many sunlight coming in, let’s block this sun and keep it cool.

When the the time is passed 20:00 o’clock in the evening:
It is getting light. Specially in summertime this will kick in. It’s not dark enough the close the roller blind but we do not want it to stay up in the evening.

If one of the above kicks in, we will enter the first ‘Then…’ flow cards. Here you’ll find three actions; set the logic to 60 (60%), start a flow for ‘too much morning sun’ (more about that later) and start the flow that sets the 60% height. If none of the above is giving a positive outcome we will head into the ‘Else …’ part which has similar actions except the morning sun flow card.

This flow runs every 1 minute regarding you are home or not. Soo every 1 minute the variable in logic is set to the desired height, even when you’re not at home. Below you’ll find the flows for doing the actual magic, which will focus on you being home. In other words; not at home? Only set the variable. At home? Set the variable and do the magic. All in one flow!

The second flow: there is too much morning sun
This flow is optional. If the blinds you are programming are setup in a direction were you have full sun sometimes you might end up using this flow as well. This one will calculate if it’s more useful to close the roller blinds all the way soo the sun is blocked and your home stays cool.

As a trigger we use ‘If this flow is started’. Scroll back up to the calculation flow, there you’ll see that this flow will be triggered once the calculation hits the 60% value.

In the ‘And …’ part we’re going to check some extra variables. If the outside temperature is higher then 20 degress celcius and if the brightness of the sensor is above 40000 LUX. This combination of values is important; only light will result in roller blinds going all the way down when some sort of lightsource hits the sensor and the amount of sun is only important when it’s warm outside. In other words, if the lightsensor kicks in in winter time for some reason it will not trigger.

Now we are going to set the height to 100% and set the variable to 100. The number stored in the variable is needed for future changes in the height.

I am using the TUYA based roller blind motor as shown above. I am using scenes to roll it up or down. Why? Please look at this post:

The last flow about the history is needed for the beta part were it checks how many times the roller blind went up and down. More about that in a future comment.

Please check the first flow. The flow to check for a strong morning sun has a 5 seconds delay. This is very important because Homey might end up hitting only 60% because the calculation is done at the exact same time. Put some time between them!

The third and fourth flow: rolling them up and down!
Soo now it’s time to really roll them up and down. We have a calculated number, we triggered these flows within the calculation and now it’s time to really do the trick.

There are two flows here; one flow for the 20% height and one for the 60% height. Look in the first flow that calculated the height for a explanation about how to call for them.

Okay soo there are no important triggers here, just a ‘when this flow starts’. This way it will run when I start it from another flow. An extra here is that you can reset the height of the blinds when you have overwritten them in an earlier stage. Run both these flows and see which one kicks in because it has the right variables to do soo!

Next let’s look at the ‘And …’ part:

The house must be turned on
This is the part of ‘is somebody actually at home?’. We use a full house trigger with a virtual device. More information about how and why here:

We are not watching a movie in theater modus
Soo when theater modus is activated our blinds are put in a 80% modus and the lights are dimmed. Once this is active we do not want the calculation to kick in; ‘please leave us alone!’ :wink:. More information about our theater modus here:

What about the privacy modus?
Soo we have a privacy mode built into Homey. This modus let’s the house act like nobody is home. Sometimes useful. I have not written a tutorial about this soo I can not add a link :slight_smile:.

The variable must be exactly 20 or 60!
This is the part were we are looking for the calculated figure. If the numeric variable is 20, the 20% flow kicks in. Is it 60? Then the 60% flow kicks in! Sounds easy, right?

Ignore the last variable, its still in beta!

Soo once every ‘And …’ has met it’s requirements, the scene for the desired height is triggered. For more information about TUYA scene triggers, scroll back up!

Searching for the right numbers …
It may be possible that you wish that the roller blinds use different numbers to change the height with. In my opinion this is the best way to do this:

  1. When the moment comes you are not satisfied with the height in combination with the sun, open your Homey app and press and hold the sensor device.
  2. Look what the amount of LUX currently is. Let’s say it’s set at 3374 LUX (just a random number I come up with); try to set a more logical to work with soo for example use 3250 here or even 3000.
  3. Go back to the calculation flow and set the new numbers.

The blinds need to go down earlier, it’s already to dark:
Change the ‘Brightness is lower than 500’ part in my first calculation flow, changing 500 in your desired number based on the number the light sensors gives you.
Ofcourse this also works the other way around, for example the roller blinds need to go down on a later moment and you wished it stays up longer.

The sun is too bright already, I wished the 60% kicks in earlier:
Change the ‘Brightness is higher than 22000’ part in my first calculation flow to your desired figure. Use the number the light sensor is giving you.
This also works the other way around, for example you think the 60% kicks in too early and you wish it stays up to 20% longer!

It’s burning hot here! The blinds need to go down to 100% faster!
Open the flow that calculates the hot morning sun, head to the ‘Brightness is higher then 40000’ and change this to the desired figure based on your sensors value.
Also this works the other way around. If the roller goes down to 100% and you think it needs to stay up, change this number as well!

In the summer I want it to stay open much longer/shorter!
Once the required bar of 500 is not reached fast enough (normally in summertime, when the daylight stays until 10 or 11 o’clock in the evening) you may wish to lower your blinds when it’s evening. Mine is set to 20:00 but you can change it to anything you like in the first calculation flow, set ‘Or the time is later than 20:00’ to your desired time.

That’s all folks!
Soo that’s all I have here for now. Hopefully this will help you build your own flows. For any questions or tips, feel free to comment!

1 Like

I haven’t read all your threads yet, but you definitely put a lot of time into them.

Thanks for the tutorials and sharing your experiences! :+1:t4:

Extra flow for lowering the blinds once your not home:

I forgot this in my post… There is a small chance that you left home, the roller blinds most go down but at the exact some time a calculation takes place soo the blind motor does not know what to do next. Since the flows are triggered only when the house is activated, the roller blinds stay up even when your not home.

I managed to build a simple flow that checks for this problem.

Every five minutes, check if the house is activated. Is it not? Trigger the scene for closing the blinds.

It’s a very simple flow, but it saves a lot of trouble :slight_smile:.

Thank you! Still changing and adding flows almost every week. I hope to give people some inspiration or solutions to problems i’ve encountered on my way here as well :slight_smile:.

U have to be careful with the “every one minute “ trigger. This flow will trigger 1440 times a day.
Along with the “every 5 minutes “ trigger u will have 1728 triggers per day, just to check lux. Homey will eventually hate u for it. And then we have the “triggered too many times” feature u will run into.
And I know, that should fire when triggering more then 10 times a second OR more then 120 times a minute but I have seen them on flows with “every 10 minutes”.

I had a trigger that went off less often which indeed asked alot from Homey, but I must say that after I updated to Homey pro I did not ran into any more problems.

I would like to roll the blinds up and down on almost live weather forecast, but indeed, if you have more flows that do this or your Homey is getting slower, you micht change this to 2, 3 or even more minutes!

I’d suggest that you change the first flow “Rolgordijn intensiteit” to, see attachted image. This is way more efficient for your homey, as Rocodamelshekima also stated.
Screenshot 2021-07-05 at 17-07-19 Homey Pro van Jeroen

I’m not sure about this, since the built in polling frequency is nearly live. Every 1 second I am getting the new LUX value. This will result in running this flow almost every second.

You could use a variable to reflect the change of Lux. For instance: If Helderheid is above or below 500 set variable X and use the state of this variable as a trigger for the flow “Rolgordijn intensiteit”, instead of the actual Lux.

Maybe use this as trigger:

Optional, but what does this bring me in processor capacity? I still need to set the variable and I still need the extra flow that’s setting this variable to trigger.

This sounds like a good option. There is actually a trigger in the Aqara&Xiaomi Zigbee app that triggers when ‘helderheid is below/above X’.

There are two ‘buts’ in this situation… One is that I will need two extra flows, soo 3 in total instead of 1. I need one for below 500, one for above 22000 and one for after 21:00 o’clock.

The second thing is; is this really soo much more efficient? The polling frequenxy is almost a second for this sensor… I can imagen that hanging a task to this frequency which will start the flow(s, 3 in total) also takes core power. Would this be soo much more less then the 1 minute flow task that’s calculating?

So u rather have 1 flow running 1700 times a day instead of 3 flows running twice a day?

If you say it like that, I guess your right. But focussing on something that triggers in the background, there will be a trigger every second?

This will only trigger when Lux goes from more then 500 to less then 500.

This is exactly the same as I was saying…just saying.

Anyway, I cannot tell you what this will bring you in processing capacity, but in another thread someone else explained it pretty well: Are homey flows "stupid" - #50 by Edwin_D

I think I do not explain my point the right way. Sorry about that.

If I use the flowcard you’re suggesting, I imagen that a underwater trigger is added. Once the LUX value is updated, Homey is executing a if/else to look if the updated value is anywere near the values i’ve set and if yes, execute the flow.

This ‘underwater trigger and check’ would run 3 times per second since the sensor is giving a new value every second.

Would this still be soo more effecient then running once per minute? Is there a way to compare?

This trigger and check is running anyway, if u do something with it or not.
I guess ur device is giving the correct results when u tell them to.

I see now. Sorry about that, indeed you meant the same thing.

I qoute this post out of the thread you’ve sent (interesting discussion by the way):

But is DOES do something every minute, especially between the given times it will send useless off commands though the mesh. Do this a lot, and the responsiveness of the devices will suffer.

On this part I must agree. In my situation, I sm sending a command to the roller blind motor over WIFI every 1 minute. This is giving a giant load on the network.

But in this same discussion, the Aqara sensor comes above as well… Stating that the underwater trigger that is seeing the ‘if sensor comes above X’ is also triggered once every X seconds.

My feeling says that a inbetween would be the better option. This is why i’ve changed my flows to this:

With this setup, I will only send a signal towards the roller blind motor once the variable is changed. This results in a signal every minute to a signal once per hour.

The load for ‘trigger when sensor value changes’ or ‘trigger every minute’ is useless in my case. This will result in ‘checking the flows every second’ soo 3x60=180 checks per minute instead of 1 per minute.

Agreed? Or am I overseeing something?

I still see the “every 1 minute” trigger.