Unable to get SUN Elevation to trigger an automation

I am trying to get my shades to trigger on sun elevation. From what I understand this should work. If I run the automation it shuts my blind but I can’t get the sun elevation to trigger it. Here is a simple automation I made to test it. Can anyone see my mistake?

alias: SunShade Down
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.sun_solar_elevation
    above: 30
conditions: []
actions:
  - device_id: ef04d2c226d7938e3db33a77f974d621
    domain: cover
    entity_id: 9274727af55de7b4ae8e55ecd0d283be
    type: close
mode: single

Does this sensor exist?

Try this trigger:

triggers:
  - trigger: numeric_state
    entity_id: sun.sun
    attribute: elevation
    above: 30

As documented here: https://www.home-assistant.io/docs/automation/trigger/#sun-elevation-trigger

For me that other sensor exists too so it should work too, provided the elevation goes from below 30 to above. It won’t trigger if it already is above. That is how state triggers work. Did you actually test it when elevation crossed over from below to above? For me in the Netherlands that would have been around 9:30. Check if there is an automation trace.

Creating it used to be in the docs, I don’t see it any more and really now that we have better attribute support there is no need.

It’s not like I made the entity: the integration did and the delete option is grayed out. I thought HA was moving away from attributes towards entities in general. But that was not why I mentioned it. I just thought the two ways should work the same, so it would probably not change what the OP experienced.

1 Like

Huh. Yeah I hadn’t looked at the sun integration for a while. It has lots of sensors now.

@tom_l The sun.sun entity no longer exists. The sun sensor was updated to sensor.sun_solar_elevation. I have played with the elevation number, 30 in my example, to observe the trigger activating, and tried different scenarios as the day progresses, none trip the automation. If sensor.sun_solar_elevation is used as a condition instead of a trigger I can use the test function and see the state turn true so I know it is sensing, but with it as a trigger, instead of a condition, there is not test function and it never activates.

It does, but it is not linked to the service, so it is very confusing:

The value needs to cross 30 for the trigger to fire. That’s likely your problem if the sensor is already above 30.

@petro When the sun is still rising and at 28 I set it to 30 and watch what happens when it gets to 30. When nothing happens I try something else and set it to 32 an watch the sun pass that point and see. So far I have not yet spotted the problem.

@Edwin_D I see the sun.sun entity but I think it only senses sunrise and sun set, not solar elevation.

Just leave it at 30 and it will trigger the automation. You can view the trace. So when it crosses the threshold tomorrow, go back and look at the automation trace to see if it triggered.

To 30, or Above 30?

What is it? I’ve never seen entity name like that…

that’s what happens when you use the UI with device triggers.

1 Like

And now today it works. Why I don’t know, although I made changes between then and now it appears to be the same as it was before? Here is what works:

alias: Sun Shade Down
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.sun_solar_elevation
    above: 40
conditions: []
actions:
  - device_id: 27204d3b97e17422dc60547cc61ec611
    domain: cover
    entity_id: 9de508fe2e97a5212508d146a1805679
    type: close
mode: single

@mirekmal Regarding your question about that entity
entity_id: 9274727af55de7b4ae8e55ecd0d283be
I recently did an update and that may have effected the behavior of the automation editor. I never entered this number.
I started editing this in the visual editor. When I selected the shade to close I had to select Device, I did not see Entity in the drop-down, I thought in the past Entity was an option in the Actions, in any event my shade was listed in human readable text as “Sun Shade 1”. When I switch to yaml editing it is now displayed as the ID number assigned to the Sun Shade 1. It automatically converted it. When I switch back to the visual editor it converts back to “Sun Shade 1”. I have a vague memory in the past of needing to use an ID number in a automation but that was regarding a state, not a device or entity. As for finding the ID to use for a state, you can find it listed in the Developer Tools under States.

1 Like

If anyone is interested this is the completed automation. This is for five exterior shades on South facing wall. The shades come down on hot days when the sun is shining in the windows. Because they are exterior heavy winds can blow them around so they will not come down if wind speed or wind gust speed is above a set amount. I have another automation that will close them if the wind picks up or the sun is no longer in the window.

alias: Sun Shade Down
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.sun_solar_elevation
    above: 40
conditions:
  - condition: state
    entity_id: cover.shade_sun_1
    state: open
  - condition: numeric_state
    entity_id: sensor.briggsstroadhouse_temperature
    above: 72
  - condition: numeric_state
    entity_id: sensor.briggsstroadhouse_wind_speed
    below: 7
  - condition: numeric_state
    entity_id: sensor.briggsstroadhouse_wind_gust_speed
    below: 14
actions:
  - device_id: 27204d3b97e17422dc60547cc61ec611
    domain: cover
    entity_id: 9de508fe2e97a5212508d146a1805679
    type: close
  - device_id: ef04d2c226d7938e3db33a77f974d621
    domain: cover
    entity_id: 9274727af55de7b4ae8e55ecd0d283be
    type: close
  - device_id: bea94b56fe4d1898288bd5248d6bd534
    domain: cover
    entity_id: 1dfb34c7b92606bfa4776220688378c9
    type: close
  - device_id: 632052aa83e250a98889cc65353d4e5b
    domain: cover
    entity_id: 50452071936ba5b0ed016397764fa619
    type: close
  - device_id: 335c6da60e36abb0df95511597efc81b
    domain: cover
    entity_id: 249de6a71b61e7851efd1b5d095d6cb6
    type: close
mode: single