09-04-2023 10:03 AM
I’m trying to have my backyard nest cam use person detection to turn on a lamp and then if there is no motion detected for 10 minutes, turn the lamp off. I also have a condition to do this only at night. I cannot get the section that turns off the light to work without errors:
metadata:
name: Backyard Motion Detected
description: When backyard camera detects person, activate living room lamp
automations:
- starters:
- type: device.event.PersonDetection
device: Backyard camera - Backyard
condition:
type: time.between
after: 22:00
before: sunrise
actions:
- type: device.command.OnOff
devices: Living Room Lamp - Living Room
on: true
- starters:
- type: device.event.MotionDetection
device: Backyard camera - Backyard
state: motionDetectionEventInProgress
is: false
for: 10 min
condition:
type: time.between
after: 22:00
before: sunrise
actions:
- type: device.command.OnOff
devices: Living Room Lamp - Living Room
on: false
09-05-2023 05:46 PM
I use this script to do what you want to do. You can add more conditions if you'd like.
metadata:
name: Doorbell Camera Person Detected Light On
description: Turn on the lights when camera sees someone.
automations:
- starters:
- type: device.event.PersonDetection
device: Doorbell - Front door
actions:
- type: device.command.OnOff
devices: Porch Light - Front door
on: true
- type: time.delay
for: 20min
- type: device.command.OnOff
devices: Porch Light - Front door
on: false
condition:
type: and
conditions:
- type: time.between
after: sunset+1hour
before: sunrise
- type: device.state.OnOff
state: on
is: false
device: Porch Light - Front door
08-10-2024 04:19 PM
This is excellent, thanks for posting! It works great for me.
One additional question. Since the doorbells have facial recognition is there a way to make an automation that play a short recording of my voice over the door bell the says "HELLO PAUL" when the doorbell see PAUL?
09-07-2023 08:41 AM
This worked! There is very little latency also which is fantastic. Final code below:
metadata:
name: Backyard Motion Detected
description: When backyard camera detects person, activate living room lamp for 10 minutes.
automations:
- starters:
- type: device.event.PersonDetection
device: Backyard Camera - Backyard
condition:
type: time.between
after: 22:00
before: sunrise
actions:
- type: device.command.OnOff
devices: Living Room Lamp - Living Room
on: true
- type: time.delay
for: 10min
- type: device.command.OnOff
devices: Living Room Lamp - Living Room
on: false
09-07-2023 05:18 PM
@kevwags which lights are supported with the script editor? I have kasa switches that are added to my google home, but I guess those are not supported.
09-07-2023 05:21 PM
well.. it appears the HS220 switch is indeed supported as an action for on/off, but for some reason the script editor is not recognizing it as a device.
09-07-2023 05:29 PM
Not sure. I am using a Govee Wi-Fi bulb.
09-07-2023 05:46 PM
I had to unlink kasa, close the app, and then re-add it!