Un-triggered sunrise automation

Hi there,

i have been working on an automation to open/tilt my covers in the morning. My goals are to

  1. Trigger the automation based on sun elevation
  2. Not trigger it before a certain time in the morning to account for early sunrise in the summer

I created the following automation, however it is not triggered, any ideas why?

(the 3rd condition is probably redundant)

- alias: "[RAFFSTORES] Kippen/Öffnen bei Sonnenaufgang"
  trigger:
  - platform: template
    value_template: "{{ state_attr('sun.sun', 'elevation') | float  >= states('input_number.schwelle_sonnenaufgang_kippen') | float }}"
  condition:
  - condition: and
    conditions:
      # trigger not before a certain time
      - condition: template
        value_template: "{{ states('sensor.time') >= (state_attr('input_datetime.raffstore_fruheste_kippzeit_morgens','timestamp') | int | timestamp_custom('%H:%M', false)) }}"
      # trigger only once per day
      - condition: template
        value_template: "{{as_timestamp(state_attr('automation.raffstores_kippen_offnen_bei_sonnenaufgang','last_triggered'))|timestamp_custom('%-d') != as_timestamp(now())|timestamp_custom('%-d')}}"
      # trigger only when sun is rising  
      - condition: template
        value_template: "{{ state_attr('sun.sun', 'rising') == true }}"
  action:
  # open covers
  - service: cover.open_cover
...

Is there a syntax error or is it not working?

Hints:

  • the use of condition: and is redundant, as conditions are AND by default.
  • you might want to replace the template trigger by a numeric state trigger, as it can use input_number natively. This way, it should only trigger once a day, rendering your 2nd condition redundant, too.
trigger:
  - platform: numeric_state
    entity_id: sun.sun
    attribute: elevation
    above: input_number.schwelle_sonnenaufgang_kippen

It is simply not triggered, no error logs, also the templates seem to be fine if I check them in the dev tools.

However I simplified my automation based on your suggestions to

################ TESTING begin
- alias: "testing kippen"
  trigger:
  - platform: numeric_state
    entity_id: sun.sun
    attribute: elevation
    above: input_number.schwelle_sonnenaufgang_kippen
  condition:
  - condition: template
    value_template: "{{ states('sensor.time') >= (state_attr('input_datetime.raffstore_fruheste_kippzeit_morgens','timestamp') | int | timestamp_custom('%H:%M', false)) }}"
  action:
...
################## TESTING END

This is working and obviously solves my problem, I still. would like to understand why my first implementation is not triggered…