When my alarm triggers I would like to know if it is a false alarm or not. The best way is to have eyes on the ground. I will show you how you can take a camera stream and show it on your smartphone. I will also be adding in a silence button to de-activate the alarm.
Table of Contents
What do I need to add a Camera Stream in Home Assistant
- Home Assistant
- An IP camera that is integrated into home assistant I’m using a Unifi Flex camera running on Unifi Protect
- Smartphone with home assistant installed and notifications enabled
- External Home Assistant instance
How to add to a White List in Home Assistant
First step go to your file editor and add a folder in the www folder under config. My folder is called photos, thereby my full path is /config/www/photos
Now we need to whitelist that folder in home assistant. Go to your configuration.yaml file and add the following:
you might already have homeassistant in your config file.
Actionable Notifications on IOS in Home Assistant
This is specific to IOS, similar for android you can find the syntax here
The SILENCE_ALARM will be used when we are looking for the ios notification event in the last part of this post when we disarm the alarm.
Identifier ‘camera’ is used in our initial notification when we send the camera stream. Important setting to note is the authenticationRequired:true which means that you need to unlock your phone to silence an alarm. An extra security feature.
- name: Camera With Actions
- identifier: 'SILENCE_ALARM'
title: 'Silence Alarm'
textInputPlaceholder: 'Send Text'
Restart HASS and then restart server and check on your app in the notification section that you can see ‘Camera With Actions’
Home Assistant Automation with Camera Stream and Alarm Silence Button
In your automations file create the following automation to send a notification when the alarm is triggered in the kitchen.
I’m using a binary sensor to find out if there is motion (to: ‘on’), condition is that the alarm panel is currently in triggered mode.
Our action is to take a snapshot of the camera with the service camera.snapshot, we need to pass the entity_id of the camera and the location in the filename.
The second service sends the notification out to your smartphone (change this accordingly). The test I’m using is “There is motion in the kitchen”, in the URL part of the attachment fill this in with your own details (externally exposed URL), I’m using Nabu Casa, which is a paid service at around $5 a month. The filename I’m using is uvc_flex.jpg feel free to change this too.
The push part of the automation enables the camera stream and the custom button set in the actionable notification.
alias: Send notifications when alarm is triggered in the kitchen
- platform: state
- service: camera.snapshot
- service: notify.mobile_app_giordano_s_iphone_7
message: "There is motion in the kitchen"
Silence an alarm panel in Home Assistant
To complete this project we need to read from the events and capture the SILENCE_ALARM actionName. This will trigger the alarm_disarm service to turn off the alarm.
You need to pass the entity id for the alarm panel and the secret code, which I stored in the secrets.yaml file.
alias: 'Silence Alarm'
code: !secret alarm_code