Missing something in this automation with sun

During the summer I need to drop the blind down when the sun is at a certain point, using the state in developer tools I have worked out it is when it below elevation 16, however this automation never triggers, what am I missing?

alias: Ln-Set-Curtain-When-Sun-Low
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.sun_elevation
    below: 16
condition: []
action:
  - device_id: 14d3863976d7b597a8a47452c0efe291
    domain: cover
    entity_id: cover.lounge_curtain_cover
    type: set_position
    position: 80
mode: single

Thanks.

Do you have this entity in your system?
sensor.sun_elevation

Because it doesn’t exist by default.


As an alternative, you can use sun.sun like this:

alias: Ln-Set-Curtain-When-Sun-Low
description: ""
trigger:
  - platform: numeric_state
    entity_id: sun.sun
    attribute: elevation
    below: 16
condition: []
action:
  - device_id: 14d3863976d7b597a8a47452c0efe291
    domain: cover
    entity_id: cover.lounge_curtain_cover
    type: set_position
    position: 80
mode: single
1 Like

in addition to the above if the sensor exists then the sensor needs to go from above 16 to below 16 for it to trigger. if the sensor state is already below 16 it won’t trigger until it transitions above and then below 16 again.

Hi there,

Yes I have the sensor, or at least I think I got it right, here’s the YAML.

  - name: "Sun Elevation"
    state: '{{ state_attr("sun.sun", "elevation" ) }}'

and it shows in the states.

I will try your version of the automation see if that works.

Thanks for your advice.