Hello - I have a Ring Spot Camera that I want to trigger my backyard lights based on motion. I’m a newbie and seeking help to configure the right settings to accomplish this. The goal is to have the lights stray on 15mins and then turn off.
Here’s the info I have in the Configuration.yaml file which turns on the lights based on motion. Now I need to build a timer that shuts the lights off after 15mins of being on.
Thanks for the help. That worked. For extra credit, I thought could add a condition to only trigger after sunset but I’m getting errors when I check the config. Here’s my script with the condition added. Did I miss something?
You had this twice. The code is ok but id must be unique. I would suggest not to use id if you are not using the front end automation editor.
So in this case HA doesn’t understand there is also another automation. Same thing with alias if you use the same twice.
For this the identation is wrong. And you are missing one line of code saying “condition”. See here example and added tips
“trigger:”, “condition:” and “action:” must have same identation.
This is easily solved by just modifying the two original automations you created.
Your first automation remains largely unchanged. Motion continues to activate the lights. However, we add a condition to check the sun’s elevation. It must be less than 0 degrees (between sunset and sunrise) to allow the action to be executed.
Thanks 123. I tried your suggestion and it seems to work but I can’t tell because it’s day here.
2 questions:
Is there a way to test this with some sort of setting to fake sunset?
I’m not really understanding how this condition is working. How does the 2nd automation know that the light has been on for 15mins?
I’m new to HA and it’s a very steep learning curve. I’m trying to be sufficient to limit the number of times I need to reach out to the community for help. Any suggestions on ways to learn HA coding?
You can temporarily replace the condition with something that you can easily toggle on/off to pretend it’s sunset/sunrise. For example, use some other light in your house (or even a door sensor).
condition:
- condition: state
entity_id: light.whatever
state: 'off'
So when light.whatever is off, we pretend that’s past sunset and when it’s on it’s past sunrise. This will allow you test the automation without having to wait for real sunset/sunrise.
How does the 2nd automation know that the light has been on for 15mins?
The trigger is effectively saying this:
I will be triggered when the backyard lights have been turned on, and have remained turned on, for at least 15 minutes.
So it won’t trigger at the moment when the backyard lights turn on but only after they’ve been on for at least 15 minutes. Effectively, it’s a 15-minute timer. When the timer expires, it triggers the automation. However, if you turn the backyard lights off while this 15-minute timer is counting down, it’ll cancel the timer. The 15-minute timer will only finish its countdown if the backyard lights remain on for an uninterrupted period of 15 minutes.
It’s my understanding that elevation represents the angle of the sun’s position relative to the horizon. So 0 is the horizon, positive numbers indicate the sun is above the horizon and negative numbers mean below it.
Um, yes, well I meant tagging the post that shows the actual solution and not the post confirming the suggested solution works. Anyway, it’s your thread so you’re free to tag it however you see fit.