Turn lights on depending on sun angle and weather conditions?

When it goes below 1 - works not too bad; needs a bit of tweaking. I took all the values and averaged them, seems to work somewhat more timely but it’s definitely WIP

I know this is a real old thread, but have you made any advancements in this template? I’m looking to do exactly this and your template seems to be the best solution I’ve found so far aside from putting an ambient light sensor outside.

1 Like

Not really – I still use elevation but it’s fixed and I factor in lux from my pir’s as well:

- alias: Lights Kitchen Home Sunset
  trigger:
    - platform: state
      entity_id: sun.sun
  condition:
    - condition: state
      entity_id: group.people
      state: 'on'
    - condition: template
      value_template: "{{ 16 < now().hour | int < 22 }}"
    - condition: or
      conditions:
      - condition: template
        value_template: "{{ states.sensor.kitchen_pir_lux.state | int <= 22 }}"
      - condition: template
        value_template: "{{ -6 < states.sun.sun.attributes.elevation | int < 10 }}"
  action:
    - service: scene.turn_on
      entity_id: scene.kitchen_bright
    - service: automation.turn_off
      entity_id: automation.lights_kitchen_home_sunset