Newbie trying to setup light control based on cloud cover, time of day, and Lutron occupancy sensors

I’ve been playing with it all with no success so far. The error goes away if I remove these new entries; but, the error comes up when putting the new stuff in and restarting core.

[automation]: [mode] is an invalid option

remove the “mode: single”

This is where my super newbie skills sink my boat… That change led to this one which I’ve tried to fight for a bit unsuccessfully.

Invalid config for [automation]: [data] is an invalid option for [automation]. Check: automation->action->0->target->data. (See /config/configuration.yaml, line 9).

Everything works when the new parts (below) are not added. Adding this causes it to hate me.

- id: '1899958999001'
  alias: 'Kitchen lights on with some cloud cover'
  trigger:
    platform: state
    entity_id:
    - binary_sensor.kitchen_occupancy
    to: 'on'
    condition:
    - condition: and
      conditions:
      - condition: numeric_state
        entity_id: sensor.openweathermap_cloud_coverage
        domain: sensor
        above: 20
        below: 49
      - condition: sun
        before: sunset
        before_offset: -01:00:00
      - condition: time
        after: '09:00'
  action:
  - service: light.turn_on
    target:
      entity_id: light.kitchen_main_lights
      data:
        brightness: 35
  - service: light.turn_on
    target:
      entity_id: light.kitchen_under_cabinet
      data:
        brightness: 60
      
- id: '1899958999002'
  alias: 'Kitchen lights off'
  trigger:
    platform: state
    entity_id:
      - binary_sensor.kitchen_occupancy
    to: 'off'
    for:
      minutes: 5
  condition: []
  action:
    - service: light.turn_off
      entity_id: light.kitchen_main_lights
    - service: light.turn_off
      entity_id: light.kitchen_under_cabinet

try data not indented

Yup, I went through a lot of issues and now it starts no errors. Getting late so I need to build out the rest to test.

Whew what a lot of learning. I hope it works out for me to continue forward.

- id: '1899958999001'
  alias: 'Kitchen lights on with some cloud cover'
  trigger:
    platform: state
    entity_id:
    - binary_sensor.kitchen_occupancy
    to: 'on'
  condition:
  - condition: and
    conditions:
    - condition: numeric_state
      entity_id: sensor.openweathermap_cloud_coverage
      above: 20
      below: 49
    - condition: sun
      before: sunset
      before_offset: -01:00:00
    - condition: time
      after: '09:00'
  action:
  - service: light.turn_on
    target:
      entity_id: light.kitchen_main_lights
    data:
      brightness_pct: 35
  - service: light.turn_on
    target:
      entity_id: light.kitchen_under_cabinet
    data:
      brightness_pct: 60
      
- id: '1899958999002'
  alias: 'Kitchen lights off'
  trigger:
    platform: state
    entity_id:
      - binary_sensor.kitchen_occupancy
    to: 'off'
    for:
      minutes: 5
  condition: []
  action:
    - service: light.turn_off
      entity_id: light.kitchen_main_lights
    - service: light.turn_off
      entity_id: light.kitchen_under_cabinet

Thank you so much so far. We seem to be in business with the below YAML should this help any other new comer.

@huu only other thought I have is what happens if let’s say the lights are on already from occupancy and the time shift means it should get brighter. Should I do something special for that?

- id: '1899958999001'
  alias: 'Kitchen lights on with some cloud cover'
  trigger:
    platform: state
    entity_id:
    - binary_sensor.kitchen_occupancy
    to: 'on'
  condition:
  - condition: and
    conditions:
    - condition: numeric_state
      entity_id: sensor.openweathermap_cloud_coverage
      above: 20
      below: 49
    - condition: sun
      before: sunset
      before_offset: -02:00:00
    - condition: time
      after: '09:00'
  action:
  - service: light.turn_on
    target:
      entity_id: light.kitchen_main_lights
    data:
      brightness_pct: 35
  - service: light.turn_on
    target:
      entity_id: light.kitchen_under_cabinet
    data:
      brightness_pct: 60
      
- id: '1899958999002'
  alias: 'Kitchen lights off'
  trigger:
    platform: state
    entity_id:
      - binary_sensor.kitchen_occupancy
    to: 'off'
    for:
      minutes: 5
  condition: []
  action:
    - service: light.turn_off
      entity_id: light.kitchen_main_lights
    - service: light.turn_off
      entity_id: light.kitchen_under_cabinet




      
- id: '1899958999003'
  alias: 'Kitchen lights on with lots of cloud cover'
  trigger:
    platform: state
    entity_id:
    - binary_sensor.kitchen_occupancy
    to: 'on'
  condition:
  - condition: and
    conditions:
    - condition: numeric_state
      entity_id: sensor.openweathermap_cloud_coverage
      above: 49
    - condition: sun
      before: sunset
      before_offset: -02:00:00
    - condition: time
      after: '09:00'
  action:
  - service: light.turn_on
    target:
      entity_id: light.kitchen_main_lights
    data:
      brightness_pct: 50
  - service: light.turn_on
    target:
      entity_id: light.kitchen_under_cabinet
    data:
      brightness_pct: 70

- id: '1899958999004'
  alias: 'Kitchen lights on with no cloud cover'
  trigger:
    platform: state
    entity_id:
    - binary_sensor.kitchen_occupancy
    to: 'on'
  condition:
  - condition: and
    conditions:
    - condition: numeric_state
      entity_id: sensor.openweathermap_cloud_coverage
      below: 20
    - condition: sun
      before: sunset
      before_offset: -02:00:00
    - condition: time
      after: '09:00'
  action:
  - service: light.turn_on
    target:
      entity_id: light.kitchen_main_lights
    data:
      brightness_pct: 30
  - service: light.turn_on
    target:
      entity_id: light.kitchen_under_cabinet
    data:
      brightness_pct: 30

- id: '1899958999005'
  alias: 'Kitchen lights evening time'
  trigger:
    platform: state
    entity_id:
    - binary_sensor.kitchen_occupancy
    to: 'on'
  condition:
  - condition: and
    conditions:
    - condition: sun
      after: sunset
      after_offset: -02:00:00
    - condition: time
      before: '22:30'
  action:
  - service: light.turn_on
    target:
      entity_id: light.kitchen_main_lights
    data:
      brightness_pct: 80
  - service: light.turn_on
    target:
      entity_id: light.kitchen_under_cabinet
    data:
      brightness_pct: 85


- id: '1899958999006'
  alias: 'Kitchen lights late night'
  trigger:
    platform: state
    entity_id:
    - binary_sensor.kitchen_occupancy
    to: 'on'
  condition:
  - condition: time
    after: '20:30'
    before: '06:00'
  action:
  - service: light.turn_on
    target:
      entity_id: light.kitchen_main_lights
    data:
      brightness_pct: 20
  - service: light.turn_on
    target:
      entity_id: light.kitchen_under_cabinet
    data:
      brightness_pct: 50

- id: '1899958999007'
  alias: 'Kitchen lights morning'
  trigger:
    platform: state
    entity_id:
    - binary_sensor.kitchen_occupancy
    to: 'on'
  condition:
  - condition: time
    after: '20:30' 
    before: '09:00'  
  action:
  - service: light.turn_on
    target:
      entity_id: light.kitchen_main_lights
    data:
      brightness_pct: 50
  - service: light.turn_on
    target:
      entity_id: light.kitchen_under_cabinet
    data:
      brightness_pct: 60