Question about sun.sun numeric_state trigger

So, looking at using Automation Triggers and decided to use sun.sun and elevation vs. a static offset for Sunset.

My understanding of this is that it should trigger once when used as a trigger, but essentially I see this execute all night long every time the sun’s elevation changes.

If I decide to turn that device off early (say to go to bed) this seems to trigger again and turn it back on. Is there a better way to trigger this (code below)

Thanks!

- id: '1589757784702'
  alias: Turn on Porch at Sunset
  description: ''
  trigger:
  - below: '-4.2'
    entity_id: sun.sun
    platform: numeric_state
    value_template: '{{ state_attr(''sun.sun'', ''elevation'') }}'
  condition: []
  action:
  - device_id: 6bfbcd45081a45038ce87b14dc7569c4
    domain: light
    entity_id: light.porch
    type: turn_on

yeah every time the state changes (elevation changes)
you could use a sun trigger?

I myself use the custom component sun2 by as a binary sensor.

# Binary Sensor for sun op or down
binary_sensor:
  - platform: sun2
    monitored_conditions:
      - elevation
      - elevation:
          above: 25
          name: Sun Above 25

sensor:
  - platform: sun2
    monitored_conditions:
      - solar_midnight
      - astronomical_dawn
      - nautical_dawn
      - dawn
      - sunrise
      - solar_noon
      - sunset
      - dusk
      - nautical_dusk
      - astronomical_dusk
      - daylight
      - civil_daylight
      - nautical_daylight
      - astronomical_daylight
      - night
      - civil_night
      - nautical_night
      - astronomical_night
      - elevation
      - max_elevation
    entity_namespace: solar

The sensor is on when the sun is above 25 in this case. My automation triggers when the sensor turns off.
Component here:

Just following up here, since I ran across this thread for a similar issue. I believe I have a solution to the “continuously triggered” problem for sun elevation. I’m a bit new to hass, so any feedback is welcome!

I’m trying to take advantage of the trigger.from_state object in the condition to make sure that the last state was above my desired threshold. It seems to be working in my testing, just need to let it run for a couple of days to make sure it behaves as expected.

- id: '1603203750260'
  alias: Afternoon Sun
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sun.sun
    attribute: elevation
    below: 40
  condition:
  - condition: numeric_state
    entity_id: sun.sun
    above: 180
    attribute: azimuth
  - condition: numeric_state
    entity_id: sun.sun
    above: 40
    value_template: '{{ trigger.from_state.attributes.elevation }}'
  action:
  - device_id: b363fe5b059011eb9bd889653556d50b
    domain: cover
    entity_id: cover.office_blinds
    type: set_position
    position: 40
  mode: single