Problem
Cameras are helpful, but most systems are triggered by a simple spider practicing bungee rope in front of them. PIRs are excellent in a security setup, but any cat or dog walking in front of them or a sudden variation in temperature will trigger them.
Goal
Create an anti-false positive, extremely reliable security system.
Prerequisite
- A functional HA
- A PC to run Blueiris
- Some Cameras (I use some Dahua & Wyze but most would do)
- A tool to clear up false positives on Cameras (I use Sentry AI)
- An MQTT server
- Some PIRs (I use Zwave ones, from NEO Coolcam, NAD-PD01Z)
- [Optional] smart speaker (like sonos)
- [Optional] AI sentry for further anti-false-positives
- [Optional] pushover
Camera config
It varies a lot based on your camera model, your network LAN/WLAN connexion quality, and many other factors. Those are broad guidelines, and nothing is set in stone.
On my Dahuas:
- Main video stream: H265 / smart codec off / 1080p / 15 FPS / CBR / 1536 kb/s / I frame: 30
- Sub video stream: H264.H /704x576 / CBR / 1024 kb/s / I frame= 50 / SVC:1
Blueiris config
Blueiris is a Windows-based camera system (NVR or VMS), able to deal with most cameras, record, detect, alert, etc. It’s supported in HA through HACS, and will pop every sensor & service needed in HA.
There are tons of parameters in there. So instead of covering them all, I’ll soon paste some screenshots of the most important ones.
[COMING SOON]
PIRs config
For neo coolcams Z-wave PIRs:
- motion sensitivity : 60
- on/off duration : 30
- re-trigger : 8
- Temp differential threshold: 100
HA group config
security:
name: Security sensors
entities:
- binary_sensor.cam1_motion
- binary_sensor.cam2_motion
- binary_sensor.cam3_motion
- ...
- binary_sensor.pir1
- binary_sensor.pir2
- binary_sensor.pir3
- ...
In your future automation, when group.security turns to on, it means one of those tilted.
HA MQTT config
From configuration.yaml:
mqtt:
binary_sensor: !include_dir_merge_list mqtt/binary_sensor
from mqtt/binary_sensor/cameras.yaml
- name: "Cam1 motion"
state_topic: homeassistant/blue_iris/binary_sensor/Cam1/state
payload_on: "on"
payload_off: "off"
device_class: motion
Add one of those entries per camera. That way, you create a binary sensor that, in combination with BI config, will turn on when there is a detection.
HA automation
- id: "110020"
alias: Alarm - Combined (3+) tiggers
description: Combine 3 different camera and motion triggers within 90s before setting off Alarm
trigger:
- platform: state
entity_id: group.security
from: "off"
to: "on"
condition:
and:
- condition: template
value_template: >
{%- set counter = namespace(total=0) %}
{%- for sensor in expand('group.security') | map(attribute='last_changed') %}
{%- if now() - sensor < timedelta(seconds=90) %}
{%- set counter.total = counter.total + 1 %}
{%- endif %}
{%- endfor %}
{{ iif(counter.total > 2 and counter.total <5, true, false) }}
- condition: state
entity_id: device_tracker.idevice_housemaid
state: "not_home"
- condition: state
entity_id: input_boolean.security_2h_snooze
state: "off"
- or:
- condition: state
entity_id: group.family_members
state: not_home
- condition: time
after: "23:00"
before: "08:00"
action:
- service: notify.emergency
data_template:
title: "ALARM!"
message: >
{{ "3 or more sensors triggered:" }}
{% for sensor in expand('group.security') -%}
{%- if sensor.state == "on" -%}
{{- " * " + state_attr(sensor.entity_id, 'friendly_name').partition(' ')[0] + "\n" -}}
{% endif %}
{%- endfor %}
data:
priority: 1
sound: bugle
- service: notify.mobile_app_k
data:
message: >
{{ "3 or more sensors triggered:" }}
{% for sensor in expand('group.security') -%}
{%- if sensor.state == "on" -%}
{{- " * " + state_attr(sensor.entity_id, 'friendly_name').partition(' ')[0] + "\n" -}}
{% endif %}
{%- endfor %}
- service: media_player.volume_set
data:
entity_id: media_player.gaming_room
volume_level: "0.7"
- service: media_player.play_media
data:
entity_id: media_player.gaming_room
media_content_type: music
media_content_id: "http://192.168.XXX.YYY:8123/local/dog.wav"
- service: camera.snapshot
entity_id: camera.blueiris_cam1
data:
filename: "/config/www/tmp/snapshot_cam1.jpg"
- service: notify.home_alert
data_template:
title: "Camera R"
message: '{{now().strftime("%H:%M %d-%m-%Y")}}'
data:
attachment: "/config/www/tmp/snapshot_cam1.jpg"
priority: 0
sound: intermission
- service: notify.mobile_app_k
data:
message: "CAM1 Live stream"
data:
entity_id: camera.blueiris_cam1
TIPS
You can adjust the sensibility of your PIRs to accommodate for the outdoor temperature using an automation. Having the dog barking on the Sonos speaker is a strong deterrent. (Provided you take a credible dog sound, there are plenty on youtube. Avoid short loops, take at least 3 minutes.) Car parking radar detectors make an excellent, rain proof & invisible 3rd possibility if you want multi-wavelength detection. They come cheap and are easy to reverse engineer to piggy back an ESP8266 + MQTT.
Disclamer
Don’t eat glue, do not jump from bridges, own risk, etc.
(My other posts: Integrate any remote to HA, Run HA boot+data on SSD with a PI, False positive proof security system, Advanced solar panel monitoring)