I have just found this Home Assistant script what calculates outdoor illuminance based on either sun elevation and current weather conditions obtained from Openweathermap. For me it would be useful to adopt it to OH because I am thinking about to schedule my blinds based illuminance.
What do you think, would it be possible to adopt it to OH?
I have an actual light sensor pointed out the kitchen window. The lighting in my flat adjusts up and down during the day based on the amount of real light coming through the windows.
I tried the virtual solar light sensor rule just to see how accurate it was. I used cloudiness as reported by the open weather map binding to weight the rule. Overall the virtual sensor reported much higher values then the real sensor but still accurately report approximate outside light. With some adjustment to the scale it could be made to work to adjust the lighting although not so much in real time, more in general (as in dawn —> midday —> dusk)
Thank you Andrew. The sript is really interesting as an experiment, but I am also not fully satisfied with that. What kind of sensor do you use? I am also considering to build or buy something.
Cheap light sensors are usually only for indoor usage, and I guess most of them send data only if they detect some motion. However your idea to put that to the window is smart. I already have some wireless Z-wave devices but z-wave usually bit more expensive then other devices.
I found the same… the Hue motion sensors worked fine in this role but needed batteries every six months because I had them set to report every 5 minutes. Cheapest mains powered sensor I could find was $70 (zwave)
So I built one myself from a esp3266 ($3) and this sensor (at the time $3 now $5 or 6) It plugs into the wall (never needs batteries) and reports every 30 seconds
With this set up the lighting in my flat adjusts in (almost) real time. Sun goes behind a cloud, lighting comes up, sun pops back out, lighting goes down. It is really cool and so sutle, you hardly notice
yes, beyond reliable, it has been running at least two or three years now. It also reports in Lux and seems well calibrated. Only problem is when I checked yesterday to figure out which sensor I used, it looks like it might be out of stock on Adafruit website or possibly discontinued but still available on Amazon. The TSL2591 looks like an updated version of the same sensor
Just to bring up an alternative idea, I built myself a simple sunshine sensor with two temperature sensors. One is placed in direct sunlight (when the sun is up), the other is in the shade. By analysing the difference you get very reliable data to detect if the sun is shining:
The sensor actually has a dynamic range that automatically switches between three ranges (I think) So it is very accurate in bright sunlight during the day but also remains accurate at much lower light level as dusk approaches. However, pointed out the window, once it is completely dark outside, it kind of goes back and forth between 2 and Nan. (maybe a car drives by with the headlights on) My rules have a ‘but only if’ clause that sets the Item to 0 if the sensor reports anything lower then 3 (just because Nan looks stupid in the user interface )
During the day, here in Florida USA, on a cloudless sunny day it can reach as high as 15,000 - 16,000 Lux. My lighting pretty much turns off at anything over 10,000 Lux because the flat is fully lit by the outside sunlight. As sunset approaches, it gets down to around 1200 - 1000 Lux. Once the sun drops below the horizon (sunset) it reports around 900. By the end of Civil dusk (about 20 minutes later) it is < 5
You can also use the Astro binding Sun phase channel, which is a string and reports NIGHT and DAYLIGHT (amongst other things) to discern if it is night time.
When the sensor is reporting anything below about 400 - 200, it is pretty much dark outside although on a really stormy cloudy day it can get below 1000. It’s very accurate, it’s practically a scientific instrument. My Hue motion sensors don’t have anywhere near the range or fidelity
So, I have anoher solution. We have kitchen windows directly to south and during winter time sun is too low and during lunch time is directly to persons, which are sitting at desk.
My solution, I bought internal sun stop blinds, I have built motorization based on DC motor with encoder and ESP32.
Based on elevation and daytime ( something like 11:30-13:30 ) I calculate simple perpendicular rectangle based on distance of desk corner from window and elevation, output is height of opened part of window, which is mapped to open percentage of window, which is sent to controller.
Regarding sun detection, I have solar panel (rated to 21V ) which charges batteries on outdoor blinds in first floor and in my case, if voltage is bellow 17V I assume that is cloudy and blinds are fully opened. Voltage level was decided based on analysis and real behavior, so is definitively specific for my usecase.
Rule is executed every minute (mostly to recalculate sunlight)
Works like perfect and all users are satisfied, we have maximum of day light and nobody needs to close eyes during lunch.
I will try to collect and publish something, so design for blinds are based on ESP-32, DRV-8872 drivers, JGA-25 Chinese motors, As it was learning project, its definitively quite dirty than clean projects.
Rule script (js) which control percentage of shades. It contains also recalculation from distance to percentage thru spiral length (formula I found somewhere on internet, but I haven’t bookmark.
Rule java script :
// distance of zero level from courtain [cm] (table corner from window glass)
// max height of courtain from desk level [cm] means dimmer=0
// min height of courtain from desk level [cm] means dimmer=100%
// measured thickenss of blind itself [cm] can be used to tune precision
// diameter of axis when we are on 100% down
// spolar power, which is understood as full sun
// full lenght of shade
// amount rotations of roller to extend from 0 to 100%
// read astro value with current angle
// var currentAngle=32;
console.log("Current Solar power is ",solarPower );
console.log("Current anle is [deg] ",currentAngle );
console.log("Current anle is [rad] ",angleRad );
console.log("Target Len is ",targetLen );
// expected rollout counted from fully open state
console.log("New Pos is ",newPos );
// new rotation position from top (means from max rotations)
var odm=Math.pow((axisDiam-thickness),2)+(4.0*thickness*newPos)/3.14159 ;
// var odm=(axisDiam-thickness)*(axisDiam-thickness) ;
// console.log("Odmocnina", odm );
console.log("Final rotations ",newRot );
console.log("Target Proc is ",targetProc );
console.log("Target Proc fin is ",Math.round(targetProc) );
console.log("Window operation finished");
Thanks for the code, @Vaclav_Bittmann. I’d be super interested in how the components are all wired together (circuit diagrams and such) as well as how it’s connected to the actual blind to move it. I would love anything you’re willing to share.
In my opinion, don’t worry about it being “dirty”. Every project is revision 1 unless you do it again. But why do it again if it’s good enough?