Calculate cloudiness based on measured light level, sun elevation and azimuth

Has anyone yet attempted to calculate the cloudiness based on the comparison of measured light level and the maximum possible light level based on sun elevation, azimuth and direction of the light level sensor?

I’m asking as I want to treat a measured light level differently based on the time of day. If it’s 7am and the sensor measures 500 lx, I can assume it’s very sunny (so I’d e.g. want to close the blinds), but if the sensor measures 500 lx at 2pm, it is probably very cloudy (so I’d e.g. want to open the blinds).

I could gather long term data and then calculate a regression manually, but maybe there’s a simpler solution. I’ve seen this project, which is somehow similar, but has a different goal, as it creates a virtual light level sensor based on the sun and the weather station cloud report: GitHub - pnbruckner/ha-illuminance: Home Assistant Illuminance Sensor

Thanks!

I have a similar requirement where I want to close a blind if it’s sunny, but only during the period in which the sun could shine through the window annoyingly. In my case azimuth was best for identifying the time period of “shining through the window”. However given that there are often dense clouds on a very sunny day, it might mean it was dark at the start of the time period, and bright sometime during. Therefore I have two automations that run (in Node Red) - one that runs at the start of the period and checks the brightness, and one that triggers if the brightness exceeds a threshold and checks the period (and the blind is not already closed).