Logic of adjusting shutters to lightlevel [more complicated than it seems]

My light sensor is outside of course.
What do you mean by increasing the delay or decreasing the trigger level?

e.g. 8 minutes and 18,000.

It won’t solve the problem.
Say my current lightlevel is 20,000. There’s a cloud and then it decreases to 17,000, and after 30 seconds it goes back to 20,000 and stays like this for half an hour. The shutters will still be closed, where in actual they’re not supposed to do any action.

Use average illumination over 30 or 60 minutes. And run an automation or NodeRed flow every 15 minutes for example and not more.

1 Like

Thanks Shaad. How do I use average illumination?

You could use the statistics sensor.

Or two of them.

Trigger when a two minute average is whatever percent below the 30 minute average you deem is needed.

I would not recommand using Statistics sensor. Or maybe it has changed. But I tested it one year ago the computed average value was not a temporal value !!!
For exemple : let’s say illumination is 0 for 9 minutes and then 10 for 1 minute, the output average over the last 10 minutes would be “5” with Statistics !!

Average Sensor is much more recommanded :
Average Sensor - Share your Projects! / Custom Components - Home Assistant Community (home-assistant.io)
From the previous example, the output average over 10 minutes would close be “1” with this component.

Or was at least… Maybe Statistics has evolved.

2 Likes

2 things :

  • Use average over 20 minutes for example and not current live value
  • Use 2 different thresholds : for example, open over 23 000, close under 17 000 instead of using 20 000 for both.

This way you will get way more hysterisis.

For which there is a binary sensor:

Thank you guys!
I installed the average sensor, and it seems to work fine. It’s already night time where I live, so I can’t test it right now.
Shaad - on Git it says - “when calculating the average, it does not take into account how much time the temperature value was kept” - Isn’t it what we wanted to avoid that occurs in the statistics sensor?

That’s talking about the disadvantages of the core statistics sensor. Which the custom average sensor overcomes.

Oh, ok then…
Great. So if it will work (and I have a good feeling it will), I will mark this thread as solved tomorrow.
Thank you very much!!

BTW, this is how the average sensor looks like on sunset, considering a 5 minutes average -

sensor

I think it looks great. Not volatile as with the original light sensor.

1 Like

Hi

One thing is not clear to me - which attribute should I take when creating an automation? What represents the light level?

Just the actual state, don’t select an attribute for what you want

Great, it works well.
Thank you everyone! This is much appreciated.

Ok, so there’s something wrong with my automation.
For some reason, every few minutes, the average light sensor triggers the action.

For example, I defined that if lux level goes above 1,000, the shutter is closed. So when it goes from 900 to 1,100 it is being closed as expected. However, it still triggers an action when it goes from 1,100 to 1,200, to 1,500 and so forth. Every time the shutter is being closed again and again.

Any solution for this?

This is how the trigger looks like:

ca

BTW, I used the same trigger template with my original light sensor (without the average) and I didn’t encounter this issue.

is the shutter already closed?

if so it just makes sure they reclose if theyve been manually opened.

you could either:

  • have a condition to check if theyre already closed.

  • have an input boolean that you triggers when you manually open them, this could then be a condition to prevent the blinds being reclosed

  • or you could use a template sensor to combine the average sensor, manual over-ride, already open etc into a single sensor, with possible values of closed, closing, opening, open, manual.
    then use the opening and closing states to trigger your blinds to open or close.

Thanks. Not all the above proposed solutions may work for me, but I kept wondering why this is not working as expected, and then it hit me - my light sensor has many attributes. How does the ‘average sensor’ know which attribute to use? How can I tell it which attribute to take?

By choosing the attribute in the attribute field.
Usually a light level sensor main state will be the light level, not an attribute though

1 Like

Ok, everything’s good now.