Sun Condition in Automation

If that is the case, try this variation of my post above.

  trigger:
    platform: state
    entity_id: binary_sensor.pir_motion
    to: 'on'
  condition:
    condition: template
    value_template: "{{ states.sun.sun.attributes.elevation | int > 8.1 }}"
  action:
    service: light.turn_on
    entity_id: light.outdoor_light

If the PIR is triggered, and the Sun is below 8°, the light will turn on. If it’s above 8°, it will do nothing.