Weather condition automation control light

Hello everyone,

I trying to setup a automation where I use weather conditions to control lights on / off.
How ever I have succeeded but only with one weather condition in one automation.
What I want is to have more than one state, like, cloudy, rainy - for light on.

I dont want to have one automation for each weather conditions…

see under:

  alias: test
  description: ''
  trigger:
  - minutes: /1
    platform: time_pattern
  condition:
  - condition: and
    conditions:
    - after: sunrise
      before: sunset
      condition: sun
    - condition: state
      entity_id: device_tracker.mm
      state: home
    - condition: state
      entity_id: weather.hjemme
      state: cloudy
  action:
  - entity_id: light.dimmable_light_1
    service: light.turn_on 
  alias: test
  description: ''
  trigger:
  - minutes: /1
    platform: time_pattern
  condition:
  - condition: and
    conditions:
    - after: sunrise
      before: sunset
      condition: sun
    - condition: state
      entity_id: device_tracker.mm
      state: home
    - condition: or
      conditions:
      - condition: state
        entity_id: weather.hjemme
        state: cloudy
      - condition: state
        entity_id: weather.hjemme
        state: rainy
  action:
  - entity_id: light.dimmable_light_1
    service: light.turn_on 

You can even drop the AND condition as that is what conditions are by default:

  alias: test
  description: ''
  trigger:
  - minutes: /1
    platform: time_pattern
  condition:
  - condition: sun
    after: sunrise
    before: sunset
  - condition: state
    entity_id: device_tracker.mm
    state: home
  - condition: or
    conditions:
    - condition: state
      entity_id: weather.hjemme
      state: cloudy
    - condition: state
      entity_id: weather.hjemme
      state: rainy
  action:
  - entity_id: light.dimmable_light_1
    service: light.turn_on 
2 Likes

Thank you, tom.

Worked perfectly.

1 Like

Ugh - having trouble doing the same thing… can someone kindly help?
This is what I have so far:

  - alias: "PORCH - on when rainy"
    trigger:
      - platform: state
        entity_id: sun.sun
        to: 'above_horizon'
    condition:
      - condition: state
        entity_id: weather.home
        state: 'rainy'
    action:
      service: switch.turn_on
      entity_id: switch.10....

But, I keep seeing this error:

    Invalid config for [automation]: Unexpected value for condition: 'None'. Expected numeric_state, state, sun, template, time, zone, and, or, not, device @ data['condition'][0]. Got None. (See /config/configuration.yaml, line 13). 

OK - I’m pretty sure that error was for something else…
I changed my automation to the following and no longer see errors.

I hope it triggers when it rains!

  - alias: "PORCH - on when RAINY"
    trigger:
      - platform: state
        entity_id: sun.sun
        to: 'above_horizon'
    condition:
      - condition: state
        entity_id: weather.home
        state: 'rainy'
    action:
      service: switch.turn_on
      entity_id: switch.10......