Hi. Well, I am certain there is a way to do this but I am stumped…
I have two motions sensors placed along my driveway. I am simply trying to create a rule/automation that tells me if someone enters (not exits). I am trying to do the automation something like: If Motion #1 is triggered and then Motion #2 is triggered within 5 seconds of Motion #1 then _____.
Which brings me to the second part of my question. Can ____ be an alert notification on my iPhone app?
I have done a similar thing on my pathway up to the house, I am pretty sure that there is maybe a better way to do it, but I achieved it by creating a toggle helper called out-not-in, then if the Motion#2 is triggered and Motion #1 has not been triggered it sets the the toggle to on for 10 seconds, when Motion #1 is triggered it checks to see if the toggle is on or off, if it’s on the it’s someone leaving, if it’s off then it’s someone coming.
Hi @itnassol ! That sounds exactly like what I am trying to do. I am kindof new to HA. Sorry to ask but can you please give me slightly more detailed instructions on how you managed to do that?
I found helpers and created a toggle called “out not in” but I am very confused on what exactly to do after that. Do I then create and automation? How do I relate that to the motions?
Hi there, Yes no problem.
You can build a multi-layered automation using trigger ID’s and the such, but for now I would use separate automations just to make things clearer for you.
Lets start with the automation coming into the drive, This should be very simple. The trigger is the Motion #1 and that will be on detecting motion, the condition is a state and the toggle you created is off, then it’s the actions, this will be anything calling a service to turn a light on for example, but you want Notifications: Send a notification via [This is where your phone goes] assuming you have installed the app on your phone.
I would get this going first, once you are receiving a message when you walk past Motion #1, you can start to build the back end, it’s always better I have found to build these things up a step at a time.
Hi! Ok, I am building this out and have most of it figured out. I did as you describe above and it works.
Where I am lost is… how the heck do I get a motion to toggle the helper? It appears that the helper’s state never changes from off to on or vice versa.
If your helper is an input_boolean (AKA a toggle), then you use the service input_boolean.turn_on or input_boolean.turn_off.
Also, if you have video cameras covering the driveway, this can be accomplished much more easily - but without knowing what the eventual goal of this is (just a notification? Open your garage door when you return home?), it’s hard to say what may or may not be an easier/better way of accomplishing that goal.
Hi @exx . Thanks for the idea of cameras. I am currently looking at new ones.
This is for a business. The main goal is the be alerted when cars come and only when they come. Not when they leave.
So my idea for doing this was to have two motions placed X feet apart. Then create a rule that says (in normal language) that if Motion 1 is triggered and then motion 2 is triggered then send me an alert notification. However, if motion 2 is triggered and then motion 1 then nothing should happen.
Sounds simple but good grief I am having such a hard time setting that up. Any help is so appreciated.
Now that works, Your next automation, is trigger Motions # 2 then the Actions is call service turn Boolean on, wait 10 seconds then turn Boolean
off. Like this…
This will trigger the Boolean to on if someone is leaving so it wont trigger the message, because of the condition in the other automation you wrote yesterday.
Depends what you feed the cameras to. If you use regular RTSP cameras with the feeds going to an intelligent NVR, such as Blue Iris, you can define “zones” in the image. For example, if you have one camera covering the driveway, and the driveway goes from left to right across the screen (with the street being to the left), you can split the driveway in half so the left is Zone A and the right is Zone B. Then in your motion triggers section, you can define a trigger that will fire when an object crosses from Zone A into Zone B. Simply do not define a trigger in the opposite direction and you won’t be alerted when they leave.
You can also configure Blue Iris to send images from the cameras in the push notifications. That way you can easily see if it’s a UPS delivery, or an employee, or something other than a customer.
Lastly, you can also use some type of AI object identification so that you are only notified when the motion is a vehicle, and not a cat or dog or something else.
I did a 3-part series that goes into all the detail needed to set this up. It’s a bit lengthy, but all the information you need to make this work is there - from the cameras, to Blue Iris (paid product), to hardware discussion, to configuring Deepstack (free, one of the many AI object detection engines), to integrating it with HA, to configuring push notifications, and on and on.
Here’s a link to part one of the series if you’re interested:
I was able to get a few of these options to work but this one seemed to be the most straightforward. Works perfect!! Thanks so much everyone!!
Little off topic but do you know if there is a way to count how many times this automation, or a specific device, is activated per day? This is for a small business and I am trying to figure out a way to keep up with traffic counts/stats.
To do that, the entity will need to have its data in long-term storage (otherwise its data will be automatically truncated to 10 days or whatever duration you may have specified). To do that, its configuration requires use of the state_class option (set to total_increasing). Therefore it will need to be a Template Sensor or Trigger-based Template Sensor.
What I envision is a Trigger-based Template Sensor that uses an Event Trigger. The automation above would post a custom event each time it detects entry. The custom event serves to trigger the Trigger-based Template Sensor which proceeds to increment its count. In other words, each time the automation detects someone entering, it sends you a notification and causes the value of the Trigger-based Template Sensor to increase by one.
The Trigger-based Template Sensor would have a second trigger, namely a Time Trigger set for 00:00, that serves to reset the Template Sensor’s value to 0. The previous day’s total count isn’t lost but remains in long-term storage and its history can be graphed.
I know these maybe newb questions so sorry if they are. Learning though. If I may get pointed in the right direction on your idea…
I followed the link for the state_class but am unsure how to actually activate that function. Do I add that to the each of the motion entry automations that we created?
Where are Trigger-Based Templates at in HA? Or is this also something that I add to each automation?