Stream a Camera from notification when Motion is Detected

*The article below contains affiliate links. If you purchase an item after clicking on that link, I will receive a commission. Thank you!

Having cameras in or around your smart home is always a great addition. The added security allows some peace of mind and it is also nice to be able to check on things when you aren’t home. But instead of randomly checking on the cameras throughout the day, it would be nice if you can be alerted when there is motion right away. Having a notification sent to your phone when there is motion is a simple enough automation, but adding a camera stream to the notification steps it up.

Prerequisites

In order to get a camera stream notification to your phone, you will need to have three things. First would be a camera integrated into your smart home. I am using a Reolink RLC-510WA in my system, which you can find on Amazon here. The second prerequisite for adding the camera stream notification is a motion sensor. The camera that I have comes with a motion sensor built-in that Home Assistant is able to utilize. Lastly, you will need a smartphone with the Home Assistant companion app installed. This walkthrough will focus on iOS notifications.

Node Red Flow

To start I will show how to add this automation using Node-Red. I prefer to use Node-Red for all of my automations in order to keep them all organized.

The Event: State Node

The automation for the camera stream when motion is detected is surprisingly simple. This only includes two nodes at the very minimum. You can add more nodes on your own to give your own flair or to expand on it, however you only need two nodes.

Two nodes required for camera stream notification
An Event State Node and iOS Notification Node

The first node will be the “Events: state” node. This node is used when you want to capture a change in the state of something. In our case, we want to know when the motion detector goes from “nothing detected” to “something detected.” The motion sensor in your setup might have it’s own responses, so make sure you check the state history of your sensor to get them correct.

Name: Name your events: state node to keep track of what device you are watching
Entity: Select the entity of the motion sensor you are watching
If state: What you need the event to change to in order to trigger this flow. The sensor built-in to my Reolink RLC-510WA reads as “off” when there is no motion detected and “on” when there is motion detected. Since I want the camera stream to start when there is motion, I will use “on” for the if state setting.

So the event state node is ready after setting those three options. This will now trigger the flow any time motion is detected from this motion sensor. Now to send the notification.

The Call Service Node

The second node in this flow will be the “Call Service” node. This is where we will send the camera stream to the phone. This node will require you to use the “notify” service and select the phone that you want to send the notification to in the “service” field.

Domain: This will be a notification so it will use the “notify” domain.
Service: The service will be the mobile app on the device in which you wish to receive the camera stream.
Data: Data is where all of the work happens in this flow. The data field for the notify domain is extremely robust, which allows us to send a camera stream directly to the device. I prefer to use JSON to format my data fields. Below I will show the code for the data field, and then we will break down each part.

{
    "message": "There is motion in the backyard",
    "title": "Motion Detected at Pool",
    "data": {
        "entity_id": "camera.pool"
    }
}

Since this is JSON, you will need to follow the formatting exactly, that includes the indentations and commas and everything.
“message”: This is the message that will be sent along to the phone.
“title”: There needs to be a title for the notification sent to the phone.
“data”: This data field is actually an array that gets sent over, so there are more JSON pairs inside of this data set.
“entity_id”: This is the camera stream you would like to open when you receive the notification.

Wiring the nodes

Once both nodes are ready, you will wire them together. Once the motion sensor detects motion, it will trigger the service node to send the notification to your phone. When you receive the notification you will see the title and the message as well as a thumbnail snapshot from the camera.

Camera stream notification as received on iPhone
iOS notification sent to phone

A long press on the notification will pull up the camera stream directly. Keep in mind most cameras in home assistant do have a delay when opening the camera stream, so this delay will still be apparent.

Long press on camera stream notification
iOS camera stream notification after long press

Home Assistant Built-In Automation

If you want to use the built-in automation engine with Home Assistant and not Node-Red the process is also straightforward. You will want to start with a new empty automation and make sure to title it properly to keep everything organized.

Triggers

Trigger Type: Use the dropdown to select “State”
Entity: Select your motion sensor
From: The state when your motion sensor does not detect motion. My sensor shows “off.”
To: The state when your motion sensor detects motion. My sensor shows “on.”

Conditions

Conditions are optional. I like to add conditions in the form of helpers here so that I can toggle notifications on or off easily.

Actions

Action Type: Use the dropdown to select “Call Service”
Service: Select the notify service for the device you want to send the notification to. These will all start with “notify.” if you want to search easily.
Message: The message to send along with the camera stream
Title: Select the checkbox and add a title to send along with the message.
Data: Select the checkbox and add the entity id of the camera you would like to stream. Follow the format below for what to type in the data field.

Data field example for camera stream notification
Data field example for camera stream notification

All done!

Leave a Reply

Your email address will not be published. Required fields are marked *