I am trying position dynamically the sun on the image setting the top: and left: calculating them out of the azimuth and elevation.
But I am stuck with how to use a template for entering the top,left position.
I’ve tried few things but nothing worked
Thank you @jcallaghan for the tip.
No its not what I want to implement. It was mostly by curiosity, since the sun entity already contains the Alt and Azm of the sun position, with a bit of spherical trigonometry i can position it on the top-view of the house and draw the sun on a virtual celestial sphere as well the sunlight direction in the house,
something like:
These attributes are not templatable out of the box. What you can do is to use card_mod, as all values are templatable there. I use it with state-icons but it should work similar with picture-elements:
Looks great! The card_mod style wouldn’t override the position in my case, for whatever reason, so I took a slightly different approach to get it working:
I would like to understand what you are doing in this formular.
It feels from the first impression like plotting a curve in this case a curve like a circle and there fore the upper half and a lower half.
But what does the 50 mean ?
A kind of offset to keep the sun and its shadow circling within the picture ?
I would prefer a different trajectory like a usual circle for half of the day from 6 to 6 and then when the sun by average has gone down a very flat curve back cause that part the suns position is irrelevant, it could be hidden.
The formula is the conversion from spherical coordinates to a projection on the house plan
The result is in % of the image dimensions, so the 50 refers to 50% of the image = center of image
The 45% is my arbitrary definition of what I liked to have as maximum radius on the horizon, when elevation=0deg (again in %)
The 45*cos(‘sun’,‘elevation’) will return the projected radial distance of the sun for the elevation
and multiplied by:
cos(‘sun’,‘azm’) will return the horizontal position
sin(‘sun’,‘azm’) will return the vertical position
The 32.7deg is an additional correction since on the scanned plan of my house the north direction was rotated by 32.7% from the vertical orientation.