Newbie Automation help condition is invalid

I’ve been struggling to get an automation where a camera detects motion during the night that will trigger some lights for 15 minutes.

This is the error I get:

Invalid config for [automation]: [condition] is an invalid option for [automation]. Check: automation->trigger->0->condition. (See /config/configuration.yaml, line 39). Please check the docs at https://home-assistant.io/components/automation/
Invalid config for [automation]: [timer] is an invalid option for [automation]. Check: automation->timer. (See /config/configuration.yaml, line 39). Please check the docs at https://home-assistant.io/components/automation/

The following is how I’m trying to do it:

- alias: Stickup Cam detects motion
  trigger:
    platform: state
    entity_id: binary_sensor.ring_backyard_2_motion
    to: 'on'
    condition: 
    condition: time
    after: '07:30'
    before: '23:30' 
  action:
  - service: homeassistant.turn_on
    data:
    entity_id:
  - light.laundry_room
  - switch.basement_switch
  - service: timer.start
    data:
  entity_id: timer.ring.backyard

- alias: Turn off Laundry/Basement Switch lights 15 minutes after trigger
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.ring.backyard
  action:
    service: homeassistant.turn_off
    data:
      entity_id:
        - light.laundry_room
        - switch.basement_switch
  timer:
  ring.backyard:
    duration: '00:15:00'

May someone point out to me what I’m doing wrong?

-Thanks

Incorrect indenting.

Move the first condition: statement to the left by two spaces. It should be aligned with trigger and action.

- alias: Stickup Cam detects motion
  trigger:
    platform: state
    entity_id: binary_sensor.ring_backyard_2_motion
    to: 'on'
  condition: 
    condition: time
    after: '07:30'
    before: '23:30' 
  action:

Thanks! I got passed that error message onto another.

Invalid config for [automation]: expected dict for dictionary value @ data[‘action’][0][‘data’]. Got None
extra keys not allowed @ data[‘entity_id’]. Got None
not a valid value for dictionary value @ data[‘action’][0][‘entity_id’]. Got None.

More indentation errors.

The action section calls two services. Each service has a data section. Everything in both data sections is incorrectly indented.

To learn the correct way to indent it, I suggest you examine the first example shown in Automation Action.

Thanks. I’m trying to correct. Used one of those on-line yaml checkers. Guess that was a bad idea lol

I’m getting this error now:

Error loading /config/configuration.yaml: while parsing a block collection
in “/config/automations.yaml”, line 22, column 1
expected , but found ‘?’
in “/config/automations.yaml”, line 84, column 1

I suspect I screwed up something within the timer section?

- alias: Stickup Cam detects motion
  trigger:
    platform: state
    entity_id: binary_sensor.ring_backyard_2_motion
    to: 'on'
  condition: 
    condition: time
    after: '07:30'
    before: '23:30' 
  action:
    service: homeassistant.turn_on
    data:
      entity_id: light.laundry_room, switch.basement_switch
      service: timer.start
    data:
      entity_id: timer.ring.backyard

- alias: Turn off Laundry/Basement Switch lights 15 minutes after trigger
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.ring.backyard
  action:
    service: homeassistant.turn_off
    data:
      entity_id: light.laundry_room, switch.basement_switch
timer:
  ring.backyard:
    duration: '00:15:00'

The first automation’s action section is still wrong.

It calls two services and doesn’t format them correctly.

Refer to the link I provided in my previous post. It shows how to correctly format action when it contains more than one service.

I get it right this time?

- alias: Stickup Cam detects motion
  trigger:
    platform: state
    entity_id: binary_sensor.ring_backyard_2_motion
    to: 'on'
  condition: 
    condition: time
    after: '07:30'
    before: '23:30' 
  action:
    service: homeassistant.turn_on
    data:
      entity_id: light.laundry_room, switch.basement_switch
    service: timer.start
    data:
      entity_id: timer.ring.backyard

No (but it’s almost correct).

Have you looked at the example in the link I posted? It clearly shows how to create an action containing more than one service.

Yes, I have looked over that web page a few times now. I’ll see if I can see something I missed…

  action:
    - service: homeassistant.turn_on
      data:
        entity_id: light.laundry_room, switch.basement_switch
    - service: timer.start
      data:
        entity_id: timer.ring.backyard

Thanks for trying to help out. I guess I must have more errors than that. LOL

Am I close with this?

##Stickup Cam
- alias: Stickup Cam detects motion
  trigger:
    platform: state
    entity_id: binary_sensor.ring_backyard_2_motion
    to: 'on'
  condition: 
    condition: time
    after: '07:30'
    before: '23:30' 
  action:
    - service: homeassistant.turn_on
      data:
        entity_id: light.laundry_room, switch.basement_switch
    - service: timer.start
      data:
        entity_id: timer.ring.backyard
- alias: Turn off Laundry/Basement Switch lights 15 minutes after trigger
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
        entity_id: timer.ring.backyard
  action:
  - service: homeassistant.turn_off
    data:
      entity_id: light.laundry_room, switch.basement_switch
timer:
  ring.backyard:
    duration: '00:15:00'

It looks good to me but, to be sure, run Configuration > General > Config Check to confirm there are no other syntax errors.

Of course, it would error out when added:

Configuration invalid CHECK CONFIG

Error loading /config/configuration.yaml: while parsing a block collection in “/config/automations.yaml”, line 22, column 1 expected <block end>, but found ‘?’ in “/config/automations.yaml”, line 81, column 1

Notice how timer: indicates it’s a section dedicated to defining timers?

You need to include automation: to indicate it’s a section dedicated to defining automations.

This is shown on the first line of the example I suggested you review.

What do you use to edit your code?
I’ve had some similar errors when using (not-well-configured) notepad++.
Try deleting the whitespace in those lines and adding single spaces manually to fix the identation.

Is that still needed when it is in the automations.yaml? I though I has an issue with a prior automation when I kept that. It started to work once removed.

I am using notepad++

No, it’s not needed if you’re putting those automations into automation.yaml. However, you shouldn’t be putting the timer in automations.yaml.