Aswin
(Mahesh)
October 2, 2026, 6:49pm
1
Hi everyone,
I want to turn on a Sonoff smart switch (Light) whenever human motion is detected on my Prama NVR / CCTV camera in Home Assistant.
Could someone guide me on the best way to trigger a light based on camera motion events or share a sample YAML code/automation logic for this setup?
Thanks!
ddaniel
(Daniel Dekovic)
October 2, 2026, 6:54pm
2
You mean like this ?
alias: Front door lights on motion
description: ''
triggers:
- trigger: state
entity_id:
- binary_sensor.doorbell_person_occupancy
id: motion
from: 'off'
to: 'on'
- trigger: state
entity_id:
- binary_sensor.doorbell_person_occupancy
from: 'on'
to: 'off'
for:
hours: 0
minutes: 3
seconds: 0
id: motion clear
- trigger: state
entity_id:
- sun.sun
to: above_horizon
id: sun
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- motion
- condition: state
entity_id: binary_sensor.night
state: 'on'
- condition: state
entity_id: switch.front_door_lights
state: 'off'
sequence:
- action: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.front_door_lights
- conditions:
- condition: trigger
id:
- motion clear
- condition: state
entity_id: binary_sensor.night
state: 'on'
- condition: state
entity_id: switch.front_door_lights
state: 'on'
sequence:
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.front_door_lights
- conditions:
- condition: trigger
id:
- sun
- condition: state
entity_id: automation.front_door_light
state: 'on'
sequence:
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.front_door_lights
mode: single
Add a trigger, select the light turning on as your target.
The best way to learn is to just try. Run thru the docs on getting started with the automation editor. If you get stuck, come back with what you have done.