Help with automated lights depending on weather

Hi all,

I am quite new to Home assistant and therefore also new to the automation parts in HA.
I have for quite a while been running automations on my lights to turn on / off depending on the sun but i would like to tweak this automation.
During winter time my automation works perfectly, since the lights in my house are triggered quite early each day ( around 14:00), however now, during summertime the lights are supposed to turn on at sunset, which is quite late, around 22:00. The issue that i would like to get your help with is that when the weather is cloudy, it is quite dark and i would like the lights to turn on, but since it only gets triggered by time, i have to do this manually.
How do i edit my automations so that the lights turn on either when it is cloudy or by time?

Here is the automation as it looks now, only depending on sun.

id: '1604239758189'
  alias: Tänd lampor när solen går ner
  description: Tänder lampor när solen går ner
  trigger:
  - platform: sun
    event: sunset
    offset: -02:00:00
  condition: []
  action:
  - type: turn_on
    device_id: a51eb27cd08be1ff45d4954f4bd0dfdd
    entity_id: switch.shellyplug_s_7aeee5
    domain: switch
  - type: turn_on
    device_id: e52cca9b5d10f62af1b2cc76723805d0
    entity_id: light.garagedorr
    domain: light
    brightness_pct: 70```

i have a similar automation for turn off.

How do i edit this automation to also trigger when "cloudy/rainy" etc?

Thanks!

Hi, the topic was discussed the other day: Simple automation based on the current weather

Alternatively: weather automation

you can use the following template sensor (modified with your equivalent entities) to give you a trigger for your automation:

sensor:
  - platform: template
    sensors:
      dark_outside:
      friendly_name: It Is Dark Outside
      value_template: >
        {% if (state_attr('sun.sun', 'elevation') | int < -2) %}
          true
        {% elif (state_attr('sun.sun', 'elevation') | int < 1) and (states('sensor.dark_sky_cloud_coverage') | int > 80) %}
          true
        {% elif (state_attr('sun.sun', 'elevation') | int < 2) and (states('sensor.dark_sky_cloud_coverage') | int > 85) %}
          true
        {% elif (state_attr('sun.sun', 'elevation') | int < 3) and (states('sensor.dark_sky_cloud_coverage') | int > 95) %}
          true
        {% else %}
          false
        {% endif %}