HomeAssistant – Not a Ringdoor bell
I’ve been using HomeAssistant now for a little over a year.
My Self-Contained HomeAssistant Installation is one of things I like the most about it. Other than nabucasa for amazon echo integration, I do not rely on any cloud services. So if the internet is out, everything still works.
My latest project was to try and emulate the functions of a ring doorbell at a fraction of the cost. I don’t need to talk back or listen at the moment, maybe that will come later.
With an inexpensive wireless door from Amazon, a well talked about Wyze cam (or Neos in the UK), and an RF bridge (flashed with tasmota), I set about creating a flow in node-red.
Installing the Firmware
The first step was to install custom firmware. I didn’t want the camera relying on an internet service to communicate with my installation. I also didn’t want the device calling home. The custom firmware is quick and easy to install. I used this video to install the firmware.
Adding the Camera to HA
Once set up and connected to wifi, It needed to be added to HomeAssistant. My Installation is running on unraid, in a docker container. Each of my docker containers are assigned individual IP addresses, on a separated vlan to my home computers. The hook up has created a great video on how to do this. My “components” are configured by type. e.g. camera.yaml, light.yaml, switch.yaml etc.
The lines below were added to the camera.yaml file, as the camera uses an rtsp feed.
platform: ffmpeg
name: neoscam3
input: -rtsp_transport tcp -i rtsp://username:Password@192.168.12.5:8554/unicast
I would recommend setting up another user for HA. Achievable on the System>Video page of the camera.
Node-Red needed access to the www folder withing HA so I mapped this with the following settings:
Note the mount point for node-red is “doorbell”.
Adding the doorbell
I added the doorbell to HomeAssistant as a binary sensor like so:
- platform: mqtt
name: "doorbell"
state_topic: "tele/RF_Bridge/RESULT"
value_template: '{{value_json.RfReceived.Data}}'
payload_on: "ABC123"
payload_off: "ABC123Off"
device_class: occupancy
qos: 1
I found the payload for doorbell by review the console output on the rf bridge. To make sure I had the correct code, I pressed the button multiple times as I had other RF traffic flowing; (PIR sensors.) I also created a flow in node red to switch the doorbell “off” after five seconds.
Creating the Flow in Node-red
I spent a long time trying to send the image directly, but I just couldn’t get it to work. I eventually used the www folder in HA as a mount point to store and link to the files. Below is my node-red flow that:
Doorbell activated > Snapshot taken > Message sent to the phone with still image > snapshot saved to nextcloud.
When I click the notification, it opens the live video feed. It is by no means perfect, and I’m sure there are other ways of doing this, but this is just my way.
[{"id":"d0a182a5.a3645","type":"tab","label":"Doorbell","disabled":false,"info":""},{"id":"cdfbf573.bd0498","type":"inject","z":"d0a182a5.a3645","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":440,"wires":[["67cbe153.5754b"]]},{"id":"a815576a.f646e8","type":"http request","z":"d0a182a5.a3645","name":"http get","method":"GET","ret":"bin","paytoqs":false,"url":"https://ha.mydomain.co.uk/api/camera_proxy/camera.PorchCam?api_password=MySuperSecretPassword","tls":"","proxy":"","authType":"","x":500,"y":440,"wires":[["3d504cb.38b63b4"]]},{"id":"cede2556.928cf8","type":"image","z":"d0a182a5.a3645","name":"","width":"600","x":1020,"y":560,"wires":[]},{"id":"3d504cb.38b63b4","type":"file","z":"d0a182a5.a3645","name":"","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"true","encoding":"none","x":630,"y":440,"wires":[["fbaa479a.866968","132c68c7.fff4c7"]]},{"id":"fbaa479a.866968","type":"nextcloud-webdav-in","z":"d0a182a5.a3645","uname":"Upload to Nextcloud","server":"b67e1ee7.6ae4a","filename":"","directory":"doorbell","x":860,"y":440,"wires":[[]]},{"id":"67cbe153.5754b","type":"function","z":"d0a182a5.a3645","name":"Set file name","func":"var d = new Date();\nvar t = d.getTime();\nvar year = d.getFullYear();\nvar month = d.getMonth()+1; \nvar day = d.getDate();\nvar h = d.getUTCHours();\nvar m = d.getUTCMinutes();\nvar s = d.getUTCSeconds();\nmsg.date = t;\nmsg.filename = '/doorbell/'+year+month+day+h+m+s+'.jpg';\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":440,"wires":[["a815576a.f646e8"]]},{"id":"5097bc8a.9cb304","type":"api-call-service","z":"d0a182a5.a3645","name":"Phone Notification (Image and Video Feed)","server":"3d7d30f6.8912c","service_domain":"notify","service":"chrome_notifier_my_phone","data":"{\"title\":\"Ding Dong\",\"message\":\"Someone rang the doorbell\",\"data\":{\"image\":\"{{{filename}}}\",\"url\":\"https://ha.mydomain.co.uk/api/camera_proxy/camera.neoscam3?api_password=MySuperSecretPassword\"}}","mergecontext":"","output_location":"","output_location_type":"none","x":730,"y":560,"wires":[["cede2556.928cf8"]]},{"id":"132c68c7.fff4c7","type":"change","z":"d0a182a5.a3645","name":"Prefix Domain Name","rules":[{"t":"change","p":"filename","pt":"msg","from":"/doorbell/","fromt":"str","to":"https://ha.mydomain.co.uk/local/doorbell/","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":560,"wires":[["5097bc8a.9cb304"]]},{"id":"52c5a24c.f479ac","type":"server-state-changed","z":"d0a182a5.a3645","name":"Doorbell","server":"3d7d30f6.8912c","entityidfilter":"binary_sensor.doorbell","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"x":180,"y":360,"wires":[["80bfa427.8c1b38"],[]]},{"id":"c1fc22b4.c6cb1","type":"api-call-service","z":"d0a182a5.a3645","name":"TTS - Someone at the front door","server":"3d7d30f6.8912c","service_domain":"notify","service":"alexa_media_everywhere","data":"{\"message\":\"There is someone at the frontdoor\",\"data\":{\"type\":\"announce\"}}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1130,"y":440,"wires":[[]]},{"id":"80bfa427.8c1b38","type":"delay","z":"d0a182a5.a3645","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"30","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":380,"y":360,"wires":[["811064fb.a798b8","67cbe153.5754b"]]},{"id":"327a58e7.418388","type":"api-call-service","z":"d0a182a5.a3645","name":"TTS - Someone at the front door","server":"3d7d30f6.8912c","service_domain":"notify","service":"alexa_media_everywhere","data":"{\"message\":\"There is someone at the frontdoor\",\"data\":{\"type\":\"announce\"}}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1130,"y":380,"wires":[[]]},{"id":"cefe16f8.a86888","type":"delay","z":"d0a182a5.a3645","name":"","pauseType":"delay","timeout":"15","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":880,"y":380,"wires":[["327a58e7.418388"]]},{"id":"811064fb.a798b8","type":"time-range-switch","z":"d0a182a5.a3645","name":"","lat":"51.374000","lon":"0.519200","startTime":"18:00","endTime":"08:00","startOffset":"-30","endOffset":0,"x":610,"y":360,"wires":[["88896708.b192c8","8d840b85.473898"],["c1fc22b4.c6cb1","cefe16f8.a86888"]],"outputLabels":["Night","Day"]},{"id":"8d840b85.473898","type":"api-call-service","z":"d0a182a5.a3645","name":"TTS - Someone at the front door","server":"3d7d30f6.8912c","service_domain":"notify","service":"alexa_media_downstairs_echos","data":"{\"message\":\"There is someone at the frontdoor\",\"data\":{\"type\":\"announce\"}}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1130,"y":260,"wires":[[]]},{"id":"88896708.b192c8","type":"api-call-service","z":"d0a182a5.a3645","name":"TTS - Someone at the front door","server":"3d7d30f6.8912c","service_domain":"notify","service":"alexa_media_bedroom_echo","data":"{\"message\":\"There is someone at the frontdoor\",\"data\":{\"type\":\"announce\"}}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1130,"y":320,"wires":[[]]},{"id":"b67e1ee7.6ae4a","type":"nextcloud-credentials","z":"","cname":"Home NextCloud","address":"https://nextcloud.mydomain.co.uk"},{"id":"3d7d30f6.8912c","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true}]
*I have firewall rules in place that block all traffic from my smart switches and cameras going out to the internet.