I’m at a loss. Trace is beyond my scope. Let me make a comment and tell me I’m wrong. When new people here ask how to do an automation to make lights go on with motion, and off with absense of motion, they get comments like “there are a hundred of these, do a search”. Well, I’ve tried about 5 that were posed, did the modifications as necessary, and none of them worked. When I get good people trying to help me, none of their solutions work. And these are experienced people (like you reading this) with an automation that would seem to be very very common.
I’m aware that HA is a work in progress, but for new people, this is really, really hard. I’m going to have to give up on this.
By the way, have you tried to use the Blueprint already available with your Home Assistant?
When creating a new automation, you are offered to create your automation from an existing blueprint and some are offered, including one named “Motion-activated Light”. That is tested by a lot of users and it is quite good and simple.
Maybe I’m misunderstanding something fundamental. Rick are you saying with this automation, I can go into Services → Automation → Create Automation → Create New Automation → 3 dots Edit in YAML, then paste it in exactly save for the name of my sensor and switch, and that should work.
Because every time I do that, I get errors and it won’t save. Specifically: Message malformed: extra keys not allowed @ data[‘0’]
My automation looks like this:
- id: '1628660691232'
alias: Lights-Turn On Front Porch Light When Front Door Cam Detects Motion
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.birch_neolink_1_motion
from: 'off'
to: 'on'
action:
- service: switch.turn_on
data: {}
target:
entity_id: light.jasco_products_43080_light
Used the automation from the blueprint, and that did turn the light off after I left for seconds, but immediately turned it back on. In other words, the light will not stay off.
Would this still happen if I was using a motion detector instead of a camera? Is that the issue? Does the camera see the light off as motion?
Are you sure you don’t have any other automation turning on your lights?
If you go to your light under Settings > Devices and Services, you will find a box showing the last entries in the Logbook related to that device. There you can see what is turning on your light right after your automation turns it off.
I wouldn’t expect any motion sensor to capture a light turning off as a motion, but if your camera is doing that, maybe you have to find a work around.
I always like more real motion sensors, even having cameras in some of the areas where I monitor for motion.
There’s always a solution, but that will require a bit more thinking for a new automation which would take in account this behavior from your camera, as some test so you discover the unknown behaviors.
Let’s try this… delete all your automations used to control this light, then go to Settings > Automations & Scenes > Create new automation > Click on the 3-dots menu at the top right and select “Edit YAML”, then paste this and save:
Basically I’m repeating your original automation (just trying to put in an easier to understand format) and adding a condition to not turn on the light until it is off for at least 3 seconds.
I am not sure what the ID does, but I do know when I was first starting, I copied someone else’s automation ID and my system basically said nice try and have a nice day.