As a newbie I could get some slap to my head. Who could do it, please?
within configuration.yaml, I added this to have the sun elevation angle, but only if over the horizon:
template:
#--------------------------------------------------------------------------------------------------
# Sun angle over Horizon
#--------------------------------------------------------------------------------------------------
- trigger:
- platform: time_pattern
minutes: "/10"
- platform: event
event_type: event_template_reloaded
- platform: homeassistant
event: start
sensor:
- name: "Sun Angle"
unique_id: "sun_over_zero"
unit_of_measurement: "°"
value_template: >-
{% if is_state('sun.sun', 'above_horizon') %}
{{ '%+.1f' | format(states.sun.sun.attributes.elevation) }}
{% else %}
{{ '+0.0f' }}
{% endif %}
Before, I tested the last 5 lines in “development tools” | “Template” | “Template Editor”, where it apparently works:
{% if is_state('sun.sun', 'above_horizon') %}
{{ '%.1f' | format(states.sun.sun.attributes.elevation) }}
{% else %}
{{ '0.0f' }}
{% endif %}
… but I can not add any chart to my lovelace, when I type “add by entity name” and say “Sun Angle” or say “sun_over_zero”.
What’s my fault?
Ouch!
Thank you!