Sign Up
Misc, Product

Using ALPR in a Smart Home

In this article, I describe how I have used Plate Recognizer Automatic License Plate Recognition (ALPR) software and the Node-RED nodes so that my Sonos can announce visitors and unknown cars pulling up my driveway.  At the end of this post, I have inserted a link to my Node-RED setup which can be imported directly into your system.

Source: My driveway upon sunrise.

Context for ALPR in a Smart Home Project

After having purchased my first Raspberry Pi, I quickly started to investigate the possibilities of using this awesome little device for smart home purposes.  I started “slow” and used the device to control my alarm, light, garage door, Sonos, etc.

I then saw a post on a Danish smart home group on Facebook where someone had integrated a license plate scanner with his smart home setup.  I was sold straight away.

In the article below, I will describe the general principles of the system that I created.  Now, to make it work, you will need to spend some time “playing around” with the different options and Node-RED nodes.

Thankfully, there is already a great plugin for Node-RED to interact with Plate Recognizer ALPR.

Activating ALPR for Smart Home Project

I signed up for the Free Trial Plate Recognizer Snapshot API Cloud service, which gives me 2500 lookups a month.  A lookup is basically any image you send to the ALPR engine in the cloud.  As a hobbyist, I am thankful for this free plan.  For commercial projects, I understand that a subscription is required per Plate Recognizer Terms & Conditions.

You will quickly run out of the free lookups if you submit images constantly and ask Plate Recognizer to analyze them. Therefore, the first thing required is to create some sort of trigger that will let Node-RED know that it needs to send an image to the Plate Recognizer API Cloud and scan for a number plate.

Source: Using a Phillips Hue Outdoor Motion Sensor to activate ALPR.

Using Phillips Hue Outdoor Motion Sensor for ALPR

I tried using the built-in motion detection on my camera, but found that it did not integrate with Node-RED.  I then tried using third-party solutions for motion detection. However, these would trigger way too often.

I therefore decided to use a motion sensor to trigger an event.  In my case, I am using the Phillips Hue Outdoor motion sensor which I have “blinded” with masking tape to make sure that I only get a positive if a car is driving into my driveway.

Optimizing ALPR for Smart Home

Every time there is movement, I can trigger a flow in Node-RED asking my camera to take a picture and see if there are any number plates in it. When a car is arriving, the motion sensor will trigger the flow and send that image over to Plate Recognizer to scan for number plates.

Source: My Node-RED flow for Plate Recognizer ALPR.

In the above, I have inserted a “throttle note” to ensure that the motion sensor does not fire constantly and only allows for one scan every minute.

After a motion event is triggered, Node-RED will take a snapshot after 3.5 seconds and again after 7 seconds.  These intervals are selected based on the layout of my driveway and should be configured to match your home.  I am using Home Assistant to take a snapshot and save it, but essentially any way of saving a still image from your camera will work.

I then move the file into the location of my Node-RED library using an “exec node” and the following command: wget -O [/data/test.jpg] [http://IP.IP. IP. IP]:8123/[Location]

Then a “file in” node is used and connected to the Plate Recognizer node.

Plate Recognizer ALPR will then output a result that you can use to, for example, play a sound file on your Sonos system announcing a visitor.

Making ALPR Usable in My Smart Home

With the above setup, every time there is movement (e.g. a person walking by) your system would announce that a visitor had arrived if their car were in the driveway.  Naturally, the system shall only announce something when the car arrives.

You will need to look into your typical “visitor pattern” to find out how to best avoid this.  In my flow at the bottom of this post, I have included some examples.

In my home one of our cars is always parked in the driveway and therefore needs to be filtered out unless it is actually arriving.  To do this, I use presence detection in Home Assistant (using the service Life360). I have then configured my system to only announce that specific car if the driver of the car (in this case my wife) has been “away” from home within the past 5 minutes.  I am using the same setup for my own car.

With the above setup, if the system detects movement AND one of the family cars, and if the person has been away from home within the past 5 minutes, then the system will only announce this car has arrived.  Pretty smart, right?

Further Optimizing ALPR for Smart Home

For visitors, you naturally do not have the option to tract their whereabouts and need to find another solution.  For this I also use the throttle node to ensure that the system will only make an announcement every X hours, days, etc.

For instance, when we have guest over, they rarely stay for more than 12 hours.  At the same time, they rarely arrive several times within 12 hours.  I have therefore configured my throttle note to only announce visitors every 12 hours. Typically, during a stay, the motion sensor will be activated numerous times be people walking around in the driveway, and the system will recognize the car every time. However, if that car has already been announced once within the past 12 hours, the system will not announce it again.

The above may not “catch” all the special cases that might arise.  For instance, when my parents are staying over, they are typically there for several days.  If the system allows for an announcement every 12 hours, the system would announce them twice a day whenever there is movement. Consequently, for my parents, I use a much longer throttle period.

Source: Sonos and Chromecast connected to my ALPR Smart Home project.

Connecting ALPR to Sonos, Chromecast etc.

Once we have a “positive” that someone has arrived and we know that they are actually arriving, we need to decide what action to take.

In my system, I have recorded an announcement of each of my “typical” visitors and one for unknown cars (just saying that “an unknown car is in the driveway”).  The output is saved into separate audio files which are then played through my Sonos system using the Sonos Nodes.

The system really has a great wow effect!

How Do I Get ALPR on Smart Home?

Just import the code from the link below into Node-RED and install the relevant nodes.

Import is done using the menu import:!

A Special Thanks!

We thank Christian Madsen for writing this article and for using Plate Recognizer to power his smart home project!

If you have done something cool with Plate Recognizer, let us know!

Contact Us

Have a question about ALPR or Parking Management Software? Contact Us

About Plate Recognizer

Plate Recognizer provides accurate, fast, developer-friendly Automatic License Plate Recognition (ALPR) software that works in all environments, optimized for your location. Sign up for a Free Trial!

Privacy Settings
We use cookies to enhance your experience while using our website. If you are using our Services via a browser you can restrict, block or remove cookies through your web browser settings. We also use content and scripts from third parties that may use tracking technologies. You can selectively provide your consent below to allow such third party embeds. For complete information about the cookies we use, data we collect and how we process them, please check our Privacy Policy
Consent to display content from Youtube
Consent to display content from Vimeo
Google Maps
Consent to display content from Google
Consent to display content from Spotify
Sound Cloud
Consent to display content from Sound