When we are not at home, we like to have control over what moves at home. Therefore, in some rooms we have set up camera surveillance. These cameras will record video when there is movement in this room and none of us are home. At the same time, a push notification is sent to our mobile with a link to live feed on the camera.
The first thing to do is integrate the camera into the Home Assistant. With us, we have standardized on Ezviz cameras. These are easy to set up using a separate integration which can be found under the “integration” menu.
When the camera is set up in Home Assistant, you have several options to make one recording. Either via Ezviz’s own services (then requires either a subscription with Ezviz or an SD card in the camera), or use Home Assistant’s solutions. We have chosen to use Home Assistant’s solutions.
Since we already have motion sensors in many rooms, to control e.g. light, then we use these to be the one who starts the automation. The next step is important to ensure peace of mind – check if there is anyone at home before making a recording of something. If no one is home, we can start recording.
To record using the service “record”. Here you choose which camera you use, and then sets the file name and length of the recording. In Node-Red which we have used for the automation here, the data is as follows:
{
"filename": "/media/folder/file_" & $moment().format("DDMMYY-hhmmss") &".mp4",
"duration": "180"
}
By entering the “code” behind the file name, Home Assistant enters the date + time automatically in the file name, then you avoid duplicates. The name of the file then becomes e.g. “file_010621-132533.mp4”
Duration is the length of the recording in seconds, in this example 3 minutes.
At the same time as the recording is started, a notification is also sent to the mobile phone with a link to the live stream for the event. The “notify” service is used here. Note – to use this you must have the Home Assistant app installed on your phone. Select the phone you want to be notified on and enter the code for what is to be sent to the phone.
{
"data": {
"attachment": {
"content-type": "jpeg"
},
"entity_id": "camera.xxxxxyyyy",
"push": {
"category": "camera"
},
"sticky": true
},
"message": "Press and hold for live-feed",
"title": "Motion detected"
}
Here you then get a message on the phone that there is movement, press and hold for live feed. If you do that, you will see live what the camera is filming.
It is not necessary to record on our own server to watch live, we have done this to be able to go back to see what happened if there was movement in the room while we were out.