Intro
Recently I’ve been in the market for a new doorbell, and I think I’ve finally found one I can live with. As we know, the smart doorbell tech is less than perfect when it comes to integrating with Home Assistant and I’ve tried several over the last year without much success.
- Nest Hello – No RTSP feed therefore no frigate without hacky solutions
- EZViZ DB* - Tricky to capture button press and fisheye video
- Amcrest AD110 – Poor quality video (glare), Poor night-vision, couldn’t get casting to my Google Hub working without delay
- Amcrest AD410 – No idea but expensive and hard to source in the UK
Wishlist
The following are the features I was after
- RTSP / Frigate
- Ability to capture button presses
- Cast to my Google Hub / Alexa Show
Foscam Video Doorbell 2K VD1 / DBW5
The Foscam met all of my requirements and then some. Below is the feature list
- 2k Video
- RTSP H264/5
- MJPEG
- 2.4Ghz / 5Ghz / Ethernet
- Google Assistant / Alexa Compatible
- API
What we will get working
I’ll show you how we can capture button presses using node-red and then trigger an automation to
announce on your smart speakers that someone is at the door and cast a live video to your devices. I’ll also show you how to get the RTSP stream into Home Assistant
Prerequisites
First of all you will have to download the foscam app and setup your device. Make sure to remember your device username / password as we will use that later to setup the stream.
Perform any pending firmware updates, the latest version 1.17.2.9_2.134.2.31 is required to get the correct API working correctly. Interestingly I had to do 2 upgrades to get on the latest version.
Download and install the desktop software VMS. I used this to set the url to call when the doorbell is pressed. Note: You can also set this up using CGI commands but using the VMS software is easier and allows you to play with some of the advanced settings.
https://www.foscam.com/downloads/app_software.html
Install the Home Assistant node-red addon.
Configuring the cameras in Home Assistant
There are 2 urls we can use to video the video feed
rtsp:// yourusername:yourpassword@cameraip:88/videoMain
This is the high res video. Note, by default this is set to H265. If you want this to be H264 you have to turn this option on in the mobile app
rtsp://username:password@cameraip:88/videoSub
This is the sub stream, now to get the video to cast to my google hub I had to set the format to MJPEG, to do this you paste the link below into your web browser, changing the username/pass etc
http://cameraip:88/cgi-bin/CGIProxy.fcgi?cmd=setSubStreamFormat&format=1&usr=yourusername&pwd=yourpassword
You can now add this cameras to home assistant using the generic camera / MJPEG camera integrations
Capturing button presses
OK so this isn’t as easy as I would like because we have to work around a limitation in home assistant. Foscam allows us to call a webhook when the doorbell is pressed but only sends a GET request rather than a POST request that Home Assistant expects. The workaround is to use Node-Red to capture this webhook and then call an automation. You could also have Node-Red toggle a switch or whatever you prefer.
First of all fire up the VMS app, connect to your doorbell and then navigate to the following in the setup page
Here I have added a url that points to my node-red server, and I’ve added an endpoint called ‘doorbell-alarm’. Note, I had to disable SSL in Node-Red for this work - you might not need to.
Next, import the following flow into Node-Red
[{"id":"dabe49dae1a5027b","type":"tab","label":"Foscam Doorbell","disabled":false,"info":"","env":[]},{"id":"92ef6e2c36db918a","type":"http in","z":"dabe49dae1a5027b","name":"","url":"doorbell-alarm","method":"get","upload":false,"swaggerDoc":"","x":200,"y":120,"wires":[["beea1568a03685c5","21a2b9903c593c18"]],"info":"http://192.168.1.50:1880/endpoint/doorbell-alarm"},{"id":"beea1568a03685c5","type":"api-call-service","z":"dabe49dae1a5027b","name":"","server":"08bb60b9054bcc48","version":5,"debugenabled":false,"domain":"automation","service":"trigger","areaId":[],"deviceId":[],"entityId":["automation.doorbell_button_pressed"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":290,"y":200,"wires":[["93a85c4d6da594dc"]]},{"id":"93a85c4d6da594dc","type":"http response","z":"dabe49dae1a5027b","name":"","statusCode":"200","headers":{},"x":440,"y":280,"wires":[]},{"id":"21a2b9903c593c18","type":"debug","z":"dabe49dae1a5027b","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":400,"y":60,"wires":[]},{"id":"08bb60b9054bcc48","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":": ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"default","statusTimeFormat":"h:m"}]
There is an automation trigger in this flow, edit it to point towards whatever automation you want to run when the doorbell button is pressed.
Automation
The final step is to create an automation. Here is mine that announced on my google devices that someone is at the door when the bell is pressed and then stream the video to my google hub.
alias: Doorbell button pressed
description: ''
trigger:
- platform: webhook
webhook_id: doorbell_webhook
id: doorbell button pressed
condition: []
action:
- service: tts.google_say
data:
entity_id: media_player.google_speakers
message: Somebody's at the door!
cache: true
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- service: media_player.play_media
data:
media_content_id: >-
http://cameraip:88/cgi-bin/CGIStream.cgi?cmd=GetMJStream&usr=yourusername&pwd=yourpassword
media_content_type: image/jpeg
target:
device_id: 9477e76aa79f4237943b2c28b18ffc6a
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- service: media_player.turn_off
data: {}
target:
device_id: 9477e76aa79f4237943b2c28b18ffc6a
mode: restart
Other options
Here are some other options you can now do which I’ll not cover in this guide
- RTSP-Simple-Server – Used to proxy the stream and therefore minimise the stress on the camera when multiple view the stream simultaneously
- Frigate – Detect and record motion events
- Double Take – Facial Recognition software
Happy hacking!