Hi there,
I finally managed, with lots of help, to build a code, that mimics the suns movement through elevation and azimuth. It outputs the correct values of elevation for each degree of azimuth in devtools.template.
Not the real compound curves of course, its just linear movement, but it should be sufficient to test roller shutter code for shading and opening and closing for the night and day cycle. without waiting a whole day to see if the code works, just track it and the roller shutter with history graph in lovelace and you get an idea what the code does.
So how do I convert that code now from devtools.template to a working entity like sun.sun elevation? It should be named test.sun elevation and test.sun azimuth.
the goal is, that test.sun azimuth updates every second by one degree and test.sun elevation should be updated at the same time with the coresponding calucated value for elevation.
this is the code that works in devtools.template
{% set a = 1 %} {# enter azimuth increments (how fast and detailed it runs) #}
{% set b = 67 %} {# enter max elevation (for the location you want to test) #}
{% set c = b - 80 %} {# no input here, calculates the lower elevation #}
{% set d = 80 / 180 * a %} {# no input here, calculates the elevation per azimuth increment#}
These are the Variables the code will run with
Upper Elevation: {{ b }}
Lower Elevation: {{ c }}
Set Increments: {{ a }}
Elevation step per increment: {{ d }}
{% set ns = namespace(y=0.0, test={}) %}
{% for z in range(10) -%}
{% for x in range(a, 361, a) -%}
{% if x <= 180 -%}
{% set ns.y = (x*d/a)+c %}
{%- else -%}
{% set ns.y = ((x-(2*(x-180)))*d/a)+c %}
{%- endif-%}
{% set ns.test = { "azimuth": x, "elevation": ns.y } %}
azimuth {{ns.test.azimuth}} elevation {{ns.test.elevation}}
{%- endfor %}
{{z - 1}}
{%- endfor %}
thanks