Help! trigger automation if only another automation triggered or if manual switch not turned on?

Hey peeps,
I got a sonoff basic with a gpio14 wall switch. (to leave the light permanently on)
Plus a camera outside which triggers the light on motion.

I have an automation to turn off the light if no motion after 15 seconds. i want that automation not to trigger if the wall switch was manually turned on or if thats not possible than if the first automation was not triggered.
the automation i have is:

- alias: Turn on Backyard light when there is movement
  trigger:
  - platform: state
entity_id: binary_sensor.BakCam_motion
to: 'on'
  condition:
  condition: or  
  conditions:
    - condition: sun
      after: sunset
    - condition: sun
      before: sunrise
    - condition: state
      entity_id: light.backyard_light
      state: 'off'  
  action:
service: light.turn_on
entity_id: light.backyard_light

- alias: Turn off Backyard light 15 Seconds after last movement
  trigger:
  - platform: state
entity_id: binary_sensor.BakCam_motion
to: 'off'
for:
  seconds: 15
  condition:
  condition: or 
  conditions:
    - condition: sun
      after: sunset
    - condition: sun
      before: sunrise
  action:
service: light.turn_off
entity_id: light.backyard_light

cheers

Your spacing is wrong just about everywhere in your automations. Make sure your indentations are set correctly. Take a look at the automation examples and specifically look at the spacing. Try to emulate that.

my spacing is wrong because when i copy it here it changes…
here is a photo instead

Copy and paste your code properly then. There are plenty of long winded posts that describe how to do that properly. No one wants to work with badly formatted code or images. We can’t copy paste and adjust your code to help out. So please, learn how to format properly.

Section 11 shows how to properly format posts. This is stickied for all new users, so you should have read it.

Here’s a video

sorry, i fixed it…
i figured out a solution, to leave the automation off and only turn on that automation from the first automation once its triggered.
the only problem is one of the conditions is to only trigger the automation if the light is “off” but it still triggers the automation when the light is “on”
is the first automation correct?

- alias: Turn on Backyard light
  trigger:
  - platform: state
    entity_id: binary_sensor.BakCam_motion
    to: 'on'
  condition:
      condition: or  
      conditions:
        - condition: state
          entity_id: light.backyard_light
          state: 'off'
        - condition: sun
          after: sunset
        - condition: sun
          before: sunrise
  action:
    - service: light.turn_on
      entity_id: light.backyard_light
    - service: automation.turn_on
      entity_id: automation.turn_off_backyard_light

- alias: Turn off Backyard light
  trigger:
  - platform: state
    entity_id: binary_sensor.BakCam_motion
    to: 'off'
    for:
      seconds: 15
  condition:
      condition: or  
      conditions:
        - condition: sun
          after: sunset
        - condition: sun
          before: sunrise
  action:
    - service: light.turn_off
      entity_id: light.backyard_light
    - service: automation.turn_off
      entity_id: automation.turn_off_backyard_light

change your first condition to this:

  condition:
    - condition: state
      entity_id: light.backyard_light
      state: 'off'
    - condition: or
      conditions:
        - condition: sun
          after: sunset
        - condition: sun
          before: sunrise

This will only turn on if the light is off and we are after sunset or before sunrise.

EDIT: Give me a minute to think about your solution to manual turn on vrs automatic.

thank you!
that fixed the light condition!
let me know if you think there is a better alternative for the issue i have

I’ve thought about it a bit and I think the way you are handling it is the ‘easiest approach’. I’d keep what you got.

Thank you for your help! Feels great to finally get some automation’s going!
By any chance would you be able to share some input on another post i created?