This guide will show how to set up a vehicle presence sensor in Home Assistant using some key new features in Last Watch. In this example, I have a camera set up on my driveway running on Blue Iris. By using two detection profiles in Last Watch, I was able to create a sensor in Home Assistant that turns on or off whenever a car is present in the driveway.

For more on setting up Last Watch, see here.

Automation Setup

First, we will set up some automations to interact with the Home Assistant API. If you have not enabled the API in home assistant, make sure you add this line to your configuration.yaml:

# Example configuration.yaml entry
api:
https://www.home-assistant.io/integrations/api/

You will also need to set up a new long-lived access token for Last Watch. The token will allow Last Watch to authenticate and create a sensor via the API. Using this token, we can set up two HTTP automations in Last Watch: one to turn the sensor on, and another to turn the sensor off.

Automation to turn on new sensor

In the example above, you need to change "ABCDEFGH" to the access token you created in Home Assistant. You also need to make sure the URL points to your HA instance. When triggered, this automation will create an entity called sensor.driveway_vehicle_presence if it does not exist, and it will set the state to on.

Next, create another automation which turns the sensor off. It will be exactly the same as the first automation but the state in the Body should be set to off.

Now we can move on to setting up the profiles.

Detection Profiles

The first profile will turn the HA sensor on whenever a car is detected in the driveway. This profile is very straightforward if you have set up profiles before. You will need to set the file pattern to match the image files generated by your AVR software.

Detect cars on the driveway camera

You may also want to use a detection mask if there are areas where other cars might be visible such as the road or neighboring property. Once the profile is saved, make sure you subscribe it to the automation which turns on the sensor:

Subscribe to the http automation

Finally, create the second profile to turn the sensor off. It should be identical to the first profile, except we will tick the Negative switch. This is a new feature in Last Watch 0.6.0 which will trigger the profile automations only if none of the relevant objects are detected on camera.

Negative Relevance profile

Save the profile and subscribe it to the automation which turns off the sensor:

Subscribe to the http automation

The setup is now complete and the automations should begin to trigger.

Demo

Here is a look at how this is working in my setup.

Detection Profiles

I have the two profiles, Driveway Car Presence and Driveway Car No Presence set up exactly as outlined in this guide. Note that these profiles are distinct from the Driveway Vehicle profile, which handles other automations when there is vehicle motion.

When a car pulls into the driveway, the motion trigger in Blue Iris will feed a snapshot into Last Watch to run the AI and handle the automations.

Relevant Detection Event

In this example you can see how I have set up the detection mask (the red transparent layer) to filter out objects in my neighbor's driveway and in the street. You can also see that one automation was run, which should be the API for setting the sensor. We can check the states page in Home Assistant to confirm that the new entity is created.

Home Assistant sensor created

Note that the sensor will stay on until it is set otherwise. There is no timeout or any other way to turn this sensor off. This is why we need a Negative profile to clear the sensor.

When the vehicle pulls out of the driveway, motion will trigger another event:

Non-relevant detection event

Now the vehicle has entered the masked area on the street and the driveway is clear. In this case the event is not relevant, but we can see that one automation was run. This is because of the Negative Relevance profile which is set up to turn off the sensor in HA when no cars are present.

Sensor turns off

Conclusion

In this guide we saw how the latest features in Last Watch can be used to set up a simple but very precise presence sensor in Home Assistant. This example would also obviously work for other object classes such as trucks, boats, or people. You could even create individual profiles to mask out different zones, like the left and right side of a two-car garage.

Once you have the sensor set up in HA you can display it or use it to trigger any of your automations. My automations are set up to play a chime and show a snapshot on my wall kiosk when a car pulls into the driveway. If I'm not home, it gets sent to my phone instead.

Thanks for reading!