Weather conditions and automation

Hello guys I want to make a sprinkler automation but want it to turn on only if the weather is clear , cloudy or patly cloudy or if its not to rain in general here is my automation will this work? ( I use darksky as weather forecast )

automation:
  - alias: 'Irrigation turn on, then off 10 minutes later'
    trigger:
      - platform: state
        entity_id: sun.sun
        to: 'below_horizon'
    condition:
      - condition: state
        entity_id: calendar.summer_automations
        state: 'on'
    condition:
        -condition: state
         entity_id: weather.dark_sky
         state: 'clear'
    condition:
        -condition: state
          entity_id: weather.dark_sky
          state: 'cloudy'
    condition:
        -condition: state
          entity_id: weather.dark_sky
          state: 'partlycloudy'
    action:
      - service: switch.turn_on
        entity_id: switch.sonoff_10004115ce
      - delay:
          minutes: 10
      - service: switch.turn_off
        entity_id: switch.sonoff_10004115ce

You use multiple conditions like that, you need to use either an OR or an AND condition.

can you give me an example ? something like that I guess?

automation:
  - alias: 'Irrigation turn on, then off 10 minutes later'
    trigger:
      - platform: state
        entity_id: sun.sun
        to: 'below_horizon'
    condition: 
     - condition: and
      - condition: state
        entity_id: calendar.summer_automations
        state: 'on'
   - condition:
     - condition: and
       - condition: state
         entity_id: weather.dark_sky
         state: 'clear'
   - condition:
      - condition: or 
        - condition: state
          entity_id: weather.dark_sky
          state: 'cloudy'
   - condition:
       - condition: or
        - condition: state
          entity_id: weather.dark_sky
          state: 'partlycloudy'
    action:
      - service: switch.turn_on
        entity_id: switch.sonoff_10004115ce
      - delay:
          minutes: 10
      - service: switch.turn_off
        entity_id: switch.sonoff_10004115ce

Right there in the docs for conditions…

I fixed it all over again Id love someone to take a look and tell me if you find anything wrong

automation:
  - alias: 'Irrigation turn on, then off 10 minutes later'
    trigger:
      - platform: state
        entity_id: sun.sun
        to: 'below_horizon'
    condition: 
      condition: and
      conditions: 
        - condition: state
          entity_id: calendar.summer_automations
          state: 'on'
         - condition: state
           entity_id: weather.dark_sky
           state: 'clear'
     condition:
       condition: or 
       conditions: 
         - condition: state
           entity_id: weather.dark_sky
           state: 'cloudy'
         - condition: state
           entity_id: weather.dark_sky
           state: 'partlycloudy'
     action:
       - service: switch.turn_on
         entity_id: switch.sonoff_10004115ce
       - delay:
          minutes: 10
       - service: switch.turn_off
         entity_id: switch.sonoff_10004115ce

You need to be a bit more careful about indentation and the use of dashes to specify list elements. This should work:

automation:
  - alias: 'Irrigation turn on, then off 10 minutes later'
    trigger:
      - platform: state
        entity_id: sun.sun
        to: 'below_horizon'
    condition: 
      - condition: state
        entity_id: calendar.summer_automations
        state: 'on'
      - condition: or 
        conditions: 
          - condition: state
            entity_id: weather.dark_sky
            state: 'clear'
          - condition: state
            entity_id: weather.dark_sky
            state: 'cloudy'
          - condition: state
            entity_id: weather.dark_sky
            state: 'partlycloudy'
    action:
      - service: switch.turn_on
        entity_id: switch.sonoff_10004115ce
      - delay:
          minutes: 10
      - service: switch.turn_off
        entity_id: switch.sonoff_10004115ce

thank you my friend now one last question im a noob in automations and in automations.yaml there is that symbol [ ] should I erase it ,write underneath or inside that?

YAML allows two ways to define a list. The first is using square brackets. The other is using the dash symbol. So [] basically means an empty list.

Generally lists, especially lists in automation.yaml, are created instead using the dash symbol to indicate the start of each list element.

So, I would delete that and enter each automation beginning with a dash:

- alias: First automation
  trigger:
  ...
- alias: Second automation
  trigger:
  ...

Does that make sense?

completely to me I just didnt know what to do with the brackets If I should remove them or write inside or underneath thank you all

you can remove the brackets and the key to the left of the empty bracket.

The automation editor puts everything in by default (id, alias, trigger, condition, action) and adds the square brackets in if whatever it is doesn’t have anything in it.

I don’t see any square brackets in your config above so I can’t really point to an example of what I’m saying. But generally if there are no conditions it will put the following in the config:

condition: []

you can delete that whole line.

FYI, I think he’s referring to the automations.yaml file created during installation, which has just:

[]

Ah, I forgot that was in there. I haven’t seen an empty automations.yaml file in a while. :slightly_smiling_face:

yes, you can delete them…