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
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.
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.
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
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?