these are the templates of the sensors shown
# tamplate
# Sonnenstand anhand der Himmelsrichtung und Tag im Jahr
- sensors:
azimuth_hof:
friendly_name: 'Azimuth Hof'
unique_id: 'azimuth_hof'
value_template: >-
{% from 'directional_azi.jinja' import directional_azi %}
{{ directional_azi('hof', states('sensor.sonne_solar_azimuth')) }}
azimuth_hofstrasse:
friendly_name: 'Azimuth Hof Starsse'
unique_id: 'azimuth_hofstrasse'
value_template: >-
{% from 'directional_azi.jinja' import directional_azi %}
{{ directional_azi('hofstrasse', states('sensor.sonne_solar_azimuth')) }}
azimuth_strasse:
friendly_name: 'Azimuth Starsse'
unique_id: 'azimuth_strasse'
value_template: >-
{% from 'directional_azi.jinja' import directional_azi %}
{{ directional_azi('strasse', states('sensor.sonne_solar_azimuth')) }}
azimuth_scheune:
friendly_name: 'Azimuth Scheune'
unique_id: 'azimuth_scheune'
value_template: >-
{% from 'directional_azi.jinja' import directional_azi %}
{{ directional_azi('scheune', states('sensor.sonne_solar_azimuth')) }}
this is the corresponding macro
located in → custom_templates/directional_azi.jinja
{% set y_day_azi = {
1:
{"hof": none,
"hofstrasse": none,
"strasse": [126,207],
"scheune": [202,232]},
13:
{"hof": none,
"hofstrasse": none,
"strasse": [123,207],
"scheune": [202,236]},
26:
{"hof": none,
"hofstrasse": none,
"strasse": [118,207],
"scheune": [202,241]},
39:
{"hof": none,
"hofstrasse": none,
"strasse": [114,207],
"scheune": [202,245]},
52:
{"hof": none,
"hofstrasse": [109,128],
"strasse": [109,207],
"scheune": [202,252]},
65:
{"hof": none,
"hofstrasse": [99,128],
"strasse": [99,207],
"scheune": [202,260]},
78:
{"hof": [94,106],
"hofstrasse": [91,128],
"strasse": [91,207],
"scheune": [202,269]},
91:
{"hof": [86,106],
"hofstrasse": [82,128],
"strasse": [82,207],
"scheune": [202,277]},
104:
{"hof": [78,106],
"hofstrasse": [74,128],
"strasse": [74,207],
"scheune": [202,285]},
117:
{"hof": [70,106],
"hofstrasse": [66,128],
"strasse": [66,207],
"scheune": [202,294]},
130:
{"hof": [67,106],
"hofstrasse": [63,128],
"strasse": [63,207],
"scheune": [202,297]},
143:
{"hof": [61,106],
"hofstrasse": [57,128],
"strasse": [57,207],
"scheune": [202,300]},
156:
{"hof": [57,106],
"hofstrasse": [53,128],
"strasse": [53,207],
"scheune": [202,306]},
169:
{"hof": [55,106],
"hofstrasse": [51,128],
"strasse": [51,207],
"scheune": [202,308]},
182:
{"hof": [55,106],
"hofstrasse": [51,128],
"strasse": [51,207],
"scheune": [202,308]},
195:
{"hof": [59,106],
"hofstrasse": [54,128],
"strasse": [54,207],
"scheune": [202,304]},
208:
{"hof": [63,106],
"hofstrasse": [59,128],
"strasse": [59,207],
"scheune": [202,299]},
221:
{"hof": [70,106],
"hofstrasse": [59,128],
"strasse": [59,207],
"scheune": [202,292]},
234:
{"hof": [78,106],
"hofstrasse": [74,128],
"strasse": [74,207],
"scheune": [202,286]},
247:
{"hof": [85,106],
"hofstrasse": [81,128],
"strasse": [81,207],
"scheune": [202,278]},
260:
{"hof": [93,106],
"hofstrasse": [89,128],
"strasse": [89,207],
"scheune": [202,270]},
273:
{"hof": [102,106],
"hofstrasse": [98,128],
"strasse": [98,207],
"scheune": [202,261]},
286:
{"hof": none,
"hofstrasse": [106,128],
"strasse": [106,207],
"scheune": [202,253]},
299:
{"hof": none,
"hofstrasse": [114,128],
"strasse": [114,207],
"scheune": [202,246]},
312:
{"hof": none,
"hofstrasse": [120,128],
"strasse": [124,207],
"scheune": [202,239]},
325:
{"hof": none,
"hofstrasse": [124,128],
"strasse": [124,207],
"scheune": [202,234]},
338:
{"hof": none,
"hofstrasse": none,
"strasse": [127,207],
"scheune": [202,232]},
351:
{"hof": none,
"hofstrasse": none,
"strasse": [126,207],
"scheune": [202,232]},
} %}
{% macro directional_azi(direction, current_azimuth) %}
{% set yd = now().timetuple().tm_yday %}
{% set keys = y_day_azi.keys() | list %}
{% set start_ind = ((keys + [yd])|sort).index(yd) - 1 %}
{% set dir_dict = y_day_azi.get(keys[start_ind]) %}
{% set dir_list = dir_dict.get(direction) %}
{{ false if dir_list is none else current_azimuth|int
in range(dir_list[0], dir_list[1]) }}
{% endmacro %}
If the azimuth is within the specifications in the table then automations are allowed to perform certain things, otherwise they are prohibited / blocked
Don’t get me wrong, of course I could ask how I do “A or B” but I still want to understand why some things are the way they are.