I am calculating the theoretical PV-yield, based on the sun elevation and azimuth.
{% if state_attr('sun.sun','elevation')>5 -%}
{% set saz = state_attr('sun.sun','azimuth')/180*pi %}
{% set sel = state_attr('sun.sun','elevation')/180*pi %}
{% set daz = -5/180*pi %} {# panel orientation wrt South #}
{% set del = 35/180*pi %} {# panel elevation wrt horizontal #}
{% set sun_cos = sin(sel)*cos(del) - cos(saz)*cos(sel)*cos(daz)*sin(del) + cos(sel)*sin(saz)*sin(del)*sin(daz) %}
{% if sun_cos>0.25 -%}
{% set pv_calc = (sun_cos-0.15)/0.85 %}
{%- else -%}
{% set pv_calc = ((sun_cos+0.25)**2)/2 %}
{%- endif %}
{%- else -%}
{% set pv_calc = 0 %}
{%- endif -%}
{{min(pv_calc * 4100,4100)}}
Note that I have some empirically determined values in the calculation, determined by fitting a lot of measured PV characteristics.
I would like to calculate this by adding this template to configuration.yaml as a sensor. However, I want to have it calculated at a regular interval, but not too often to limit the load on the system. I suppose that the sun.sun elevation attribute gets updated indefinitely frequent, in theory. For normal sensor values, based on measured inputs, it is logical to calculate the dependent variables as soon as an input gets updated, but in this case, I have a purely calculated value as input.
How do I set the update rate of such a calculated “sensor” value?