I use the code below. At the part “{% elif is_state(‘sun.sun’, ‘below_horizon’) and now().hour < 19 %}” i would like to add some offset to the sun.sun part.
The lights switched if “Dag” (day) goes to “Vooravond” (eve) are put on manually already if we wait till below_horizon time.
- platform: template
sensors:
dagdeel:
friendly_name: ‘Dagdeel’
value_template: >-
{%- if now().hour >= 19 and now().hour < 22 %}
avond
{% elif ( now().hour >= 22 and now().hour < 24 ) or ( now().hour >= 0 and now().hour < 6 ) %}
nacht
{% elif ( now().hour >= 6 and now().hour < 10 ) %}
ochtend
{% elif is_state(‘sun.sun’, ‘below_horizon’) and now().hour < 19 %}
vooravond
{% else %}
dag
{%- endif %}