Turn on lamp if cloudy

Hi I am trying to get a lamp to go on in the day if cloudy
tried this

> - alias: 'Turn on lamp'
>   trigger:
>    - platform: numeric_state
>      entity_id: sensor.yr_cloudiness
>      above: 20
>      for:
>      minutes: 10
>       
>   condition:
>     - condition: state
>       entity_id: sun.sun
>       state: 'above_horizon'
>     - condition: numeric_state
>       event: sensor.yr_cloudiness
>       above: 20
>   action:
>     - service: light.turn_on
>       data:
>       entity_id: 
>            - light.82726627c82b96ce8f48 #Lamp Bulb

and I am getting this
Configuration invalid

                      Invalid config for [automation]: [event] is an invalid option for [automation]. Check: automation->condition->1->event. (See /config/configuration.yaml, line 69). 

this is what I have starting line 66

# Cloud
cloud:

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

How can I correct?

I do have this in integrations if it could help

Also I am using in persons device_tracker.sm_g988w

How can I integrate to use above only if home

Thanks

Hi Aqus555,
It looks like the second condition should read ‘entity_id: sensor.yr_cloudiness’ rather than ‘event: sensor.yr_cloudiness’.
Nick

1 Like

I tried the change now getting

Configuration invalid

                      Invalid config for [automation]: expected dict for dictionary value @ data['action'][0]['data']. Got None. (See /config/configuration.yaml, line 69).

Hi,

This is my full automation for comparison. This one is working for me.

- id: '1601440159918'
  alias: light on if cloudy outside
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.owm_cloud_coverage
    above: '50'
    for: 00:10:00
  condition:
  - condition: state
    entity_id: sun.sun
    state: above_horizon
  - condition: numeric_state
    entity_id: sensor.owm_cloud_coverage
    above: '20'
  action:
  - service: switch.turn_on
    data: {}
    entity_id: switch.kogan_plug_01
  mode: single

Try something like

 - alias: 'Turn on lamp'
   trigger:
    - platform: numeric_state
      entity_id: sensor.yr_cloudiness
      above: 20
      for:
        minutes: 10
       
   condition:
     - condition: state
       entity_id: sun.sun
       state: 'above_horizon'
     - condition: numeric_state
       event: sensor.yr_cloudiness
       above: 20
   action:
     - service: light.turn_on
       data: {}
       entity_id: light.82726627c82b96ce8f48

what sensors are you usinfg in the config file?
please show me the way it is written so I can insert in mine.
thanks

This is straight from your config, just fixed.

Using two different lights to test.
version from nickh66 and KYIbow modified with Met.no using weather home.
Not getting anymore errors but lights are not going on. Although in Met.No my card says rainy.

If I do a manual execute on both lights turn on. But not automatically after set time. Using 1 minute in 2nd just to test…

Not familiar with Met.no(weather.home) so what do I use for cloud coverage?

- alias: light on lamp led if cloudy outside
  trigger:
   - platform: numeric_state
     entity_id: sensor.owm_cloud_coverage
     above: '50'
     for: 00:10:00
  condition:
  - condition: state
    entity_id: sun.sun
    state: above_horizon
  - condition: numeric_state
    entity_id: sensor.owm_cloud_coverage
    above: '20'
  action:
  - service: homeassistant.turn_on
    entity_id: 
        - light.eb3394a8311202517ea1t8 #lamp led
        
        
- alias: light on lamp bulb if cloudy outside
  trigger:
   - platform: numeric_state
     entity_id: weather.home
     above: '20'
     for: 00:1:00
  condition:
  - condition: state
    entity_id: sun.sun
    state: above_horizon
  - condition: numeric_state
    entity_id: weather.home
    above: '20'
  action:
  - service: homeassistant.turn_on
    entity_id: 
        - light.82726627c82b96ce8f48 #Lamp Bulb

ok cleaned out a few things this morning. re-installed open weather map.
This morning after sunrise went from sunny to cloudy waited 15 minutes and lights still not going on.
What can be wrong. here is my latest version in automation


- alias: light on lamp led if cloudy outside
  trigger:
  - platform: numeric_state
    entity_id: sensor.owm_cloud_coverage
    above: '20'
    for: 00:10:00
  condition:
  - condition: state
    entity_id: sun.sun
    state: above_horizon
  - condition: numeric_state
    entity_id: sensor.owm_cloud_coverage
    above: '20'
  action:
  - service: homeassistant.turn_on
    entity_id:
    - light.eb3394a8311202517ea1t8 #lamp led

Well first of all, remove the duplicate condition.
Second, can you verify sensor.owm_cloud_coverage is above 20?
Third, does it show that it ran the automation recently, but the lights didn’t turn on anyway?

ok think I figured it out damn copy paste :slight_smile:

Here is the automation if it can help anyone else with the right sensor.
All works now thanks for your help

- alias: light on lamp led if cloudy outside
  trigger:
  - platform: numeric_state
    entity_id: sensor.openweathermap_cloud_coverage
    above: '20'
    for: 00:10:00
  condition:
  - condition: state
    entity_id: sun.sun
    state: above_horizon
  action:
  - service: homeassistant.turn_on
    entity_id:
    - light.eb3394a8311202517ea1t8 #lamp led

think I spoke too soon. For some reason it is not triggering.
In last days think it triggered once or twice in mid afternoon although cloud coverage is 50% and above all day last few days.

BTW here is a pic of the automatons. It does say never triggered due to I rebooted about an hour ago.

All other automatons in my system work and have much more complicated ones.




tried looking at log files and can’t see anything since it is being bombarded with wanings, I will start a new treas for this.

First of all, if that’s overloading your log, try this:

logger:
  logs:
    urllib3.connectionpool: ERROR

Second, was HA on while it changed from 20% to higher? This will only trigger once, when it goes from higher from 20%.

Thanks for the logger info. My log is now full but usefull information.

For lamp on cloud
Not sure if it was on. But it is been cloudy for days and at sunset my lights are all programmed to shut off at sunset.
therfore if it is already cloudy at sunrise it won’t trigger right?

Can I add something like this to verify every 10 minutes

trigger:
  - minutes: /10
    platform: time_pattern

or other ideas ? So if it is always cloudy and missed trigger it will never go on
thanks

Yeah, but then if you don’t want it to be on it’ll go on every 10 minutes. Just change the trigger to that and use a numeric state condition.

not sure if this is what you mean.

- alias: light on lamp led if cloudy outside
  trigger:
  - platform: numeric_state
    entity_id: sensor.openweathermap_cloud_coverage
    above: '20'
    for: 00:10:00
    trigger:
  - platform: time_pattern
    minutes: /10
  condition:
  - condition: state
    entity_id: sun.sun
    state: above_horizon
  action:
  - service: homeassistant.turn_on
    entity_id:
    - light.82726627c82b96ce8f48

Here:

- alias: light on lamp led if cloudy outside
  trigger:
  - platform: time_pattern
    minutes: /10
  condition:
  - condition: state
    entity_id: sun.sun
    state: above_horizon
  - platform: numeric_state
    entity_id: sensor.openweathermap_cloud_coverage
    above: '20'
  action:
  - service: light.turn_on
    entity_id:
    - light.82726627c82b96ce8f48

thanks :slight_smile: I will try

oops got this

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

Change platform: numeric_state to condition.