A sensor to indicate if sun is above terrain at current location. Sensor to be configured by user describing the surrounding terrain as a collection of pairs of values where various terrain elevations is given for arbitrary azimuths. Elevations for in-between azimuth calibration points to be interpolated. The more azimuth/elevation points configured, the better approximation to actual terrain.
I doubt this will ever find a way in HA core, sorry to say.
The best you can get at the moment is the custom_component
from @pnbruckner
, called “Sun2”.
The changes in this integration were suggested to get integrated into core, but were rejected as to complicated for core.
I’d recommend you take a look at that integration
You can do it without a custom component. Just add a binary sensor where elevation is greater than X, X being where the sun is over terrain,
You would have to compare a list of azimuths as well as elevations, complicating that simple binary template sensor quite a bit.
The rise and set locations change depending on the time of year.
There are pretty advanced blueprints to help you make the most of sun calculations (though not exactly what you asked):
Having said that, I can understand an estimation technique like the sun or sun2 integration will do quite well for most purposes. It will even do fine if mountains are evenly distributed using elevation. Those are neat features.
However, if that isn’t good enough, then sure: You could add support for mountains of various hight, cloud coverage, solar eclipse. Then you could also compensate for cloud reflection, add ray tracing to calculate reflections of the nearby lake or neighbors windows… OR…
You could also buy a lux sensor and find out what you want to know exactly, namely how much light is there. Measure what you want to know instead of trying to model all things that you need to estimate it accurately. I am very happy with the Aqara zigbee light sensors.
Which ones do you use?
I used Xiaomi YTC4043GL,Mi Light sensors, but they are superseded by the T1 version GZCGQ11LM, which looks exactly the same.
I even have them outside, but under a tranparent plastic cap (open at the bottom, but shielded from rain) made trom a small bottle. They survived there for about two years now with no problems whatsoever other than one battery replacement.