I thought I’d share some of the automations I’ve created using Node Red for the Doorbell.
When someone rings my doorbell:
- My mobile will open the Reolink app
- I get a notification with a snapshot on my phone and my phone will say that someone has rang the door.
When the doorbell detects a person:
- I get a silent notification with a snapshot on my phone
When the door is opened:
- It will delete all notifications from the last 2 minutes from my mobile (e.g. for when you or visitors came to the door and then the door was opened).
- It will block person detected notifications for the next 5 minutes (it will not block the notifications that someone rang the doorbell) (e.g. for when you or the visitors leave the house or you stay chatting at the door for a while).
I will still make this a bit more advanced so that it only does the blocking/clearing of notifications when my alarm system is turned off.
I am also hoping Reolink will enable using the recorded replies using their API. This way I can turn the notifications to my mobile into actionable notifications that will make the doorbell speak those recorded replies (e.g. “leave the package at the front door”, “I’ll be there in a minute”,…)
Here’s how it looks like:
And here’s the code:
[{"id":"17ba3ee684df66c7","type":"debug","z":"34843a6c.50d986","name":"Rest of the flow to sent the notification to your mobile","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1440,"y":3320,"wires":[]},{"id":"0752823e83de2258","type":"server-state-changed","z":"34843a6c.50d986","name":"Doorbell pressed","server":"5c29d263.09d2ac","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.reolink_video_doorbell_poe_visitor","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"for":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":520,"y":3300,"wires":[["7222b8be2f1b5e83","9f92b71da6ee18f0","65c02a7035839da5"],[]]},{"id":"dec8447e270e4ce0","type":"change","z":"34843a6c.50d986","name":"Define parameters","rules":[{"t":"set","p":"imageretrieveURL","pt":"msg","to":"\"/api/camera_proxy/camera.reolink_video_doorbell_poe_sub\"","tot":"jsonata"},{"t":"set","p":"NotifyType","pt":"msg","to":"TTSandNormal","tot":"str"},{"t":"set","p":"title","pt":"msg","to":"Iemand heeft aangebeld","tot":"str"},{"t":"set","p":"message","pt":"msg","to":"\" \"","tot":"jsonata"},{"t":"set","p":"TTSmessage","pt":"msg","to":"title&\" \"&message","tot":"jsonata"},{"t":"set","p":"who","pt":"msg","to":"john&jane","tot":"str"},{"t":"set","p":"clickaction","pt":"msg","to":"app://com.mcu.reolink","tot":"str"},{"t":"set","p":"actioncode1","pt":"msg","to":"","tot":"str"},{"t":"set","p":"actiontitle1","pt":"msg","to":"","tot":"str"},{"t":"set","p":"actioncode2","pt":"msg","to":"","tot":"str"},{"t":"set","p":"actiontitle2","pt":"msg","to":"","tot":"str"},{"t":"set","p":"actioncode3","pt":"msg","to":"","tot":"str"},{"t":"set","p":"actiontitle3","pt":"msg","to":"","tot":"str"},{"t":"set","p":"tag","pt":"msg","to":"newtimestamp","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1130,"y":3320,"wires":[["17ba3ee684df66c7"]]},{"id":"110605174da8c81c","type":"server-state-changed","z":"34843a6c.50d986","name":"Person detected","server":"5c29d263.09d2ac","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.reolink_video_doorbell_poe_person_detected","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"for":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":520,"y":3440,"wires":[["0c2b4970293443e8"],[]]},{"id":"53763c03b2b6aefd","type":"change","z":"34843a6c.50d986","name":"Define parameters","rules":[{"t":"set","p":"imageretrieveURL","pt":"msg","to":"\"/api/camera_proxy/camera.reolink_video_doorbell_poe_sub\"","tot":"jsonata"},{"t":"set","p":"NotifyType","pt":"msg","to":"silent","tot":"str"},{"t":"set","p":"title","pt":"msg","to":"Persoon bij voordeur","tot":"str"},{"t":"set","p":"message","pt":"msg","to":"\" \"","tot":"jsonata"},{"t":"set","p":"TTSmessage","pt":"msg","to":"title&\" \"&message","tot":"jsonata"},{"t":"set","p":"who","pt":"msg","to":"john&jane","tot":"str"},{"t":"set","p":"clickaction","pt":"msg","to":"app://com.mcu.reolink","tot":"str"},{"t":"set","p":"actioncode1","pt":"msg","to":"","tot":"str"},{"t":"set","p":"actiontitle1","pt":"msg","to":"","tot":"str"},{"t":"set","p":"actioncode2","pt":"msg","to":"","tot":"str"},{"t":"set","p":"actiontitle2","pt":"msg","to":"","tot":"str"},{"t":"set","p":"actioncode3","pt":"msg","to":"","tot":"str"},{"t":"set","p":"actiontitle3","pt":"msg","to":"","tot":"str"},{"t":"set","p":"tag","pt":"msg","to":"newtimestamp","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1310,"y":3440,"wires":[["03c1f1ecf28cc7a5"]]},{"id":"9f92b71da6ee18f0","type":"api-call-service","z":"34843a6c.50d986","name":"Launch Reolink app on mobile john","server":"5c29d263.09d2ac","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_mobile_john","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"command_launch_app\",\"data\":{\"package_name\":\"com.mcu.reolink\",\"importance\":\"high\",\"priority\":\"high\"}}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":790,"y":3240,"wires":[[]]},{"id":"7222b8be2f1b5e83","type":"api-call-service","z":"34843a6c.50d986","name":"Launch Reolink app on mobile jane","server":"5c29d263.09d2ac","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_mobile_jane","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"command_launch_app\",\"data\":{\"package_name\":\"com.mcu.reolink\",\"importance\":\"high\",\"priority\":\"high\"}}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":800,"y":3280,"wires":[[]]},{"id":"a2993d8364640c05","type":"function","z":"34843a6c.50d986","name":"Remove old values","func":"var timestamps = msg.timestamps || [];\ncontext.set(\"timestamps\", timestamps);\nvar d = new Date();\nvar fiveHoursAgo = new Date(d.getTime() - 5 * 60 * 60 * 1000);\nvar filteredTimestamps = context.get(\"timestamps\").filter(function (timestamp) {\n var timestampDate = new Date(timestamp.substring(0, 4), parseInt(timestamp.substring(4, 6)) - 1, timestamp.substring(6, 8), timestamp.substring(8, 10), timestamp.substring(10, 12), timestamp.substring(12, 14));\n return timestampDate >= fiveHoursAgo;\n});\ncontext.set(\"timestamps\", filteredTimestamps);\nmsg.timestamps = context.get(\"timestamps\");\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":890,"y":3780,"wires":[["6089532eb9cf0cce"]]},{"id":"caac07d236774cd0","type":"inject","z":"34843a6c.50d986","name":"Daily","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 07 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":510,"y":3780,"wires":[["15f806a7e20ff379"]]},{"id":"d5a6fd2dd32f3be0","type":"function","z":"34843a6c.50d986","name":"AddTimestamp","func":"var timestamps = msg.timestamps || [];\ncontext.set(\"timestamps\", timestamps);\nvar d = new Date();\nvar timestamp = d.getFullYear().toString() + (d.getMonth() + 1).toString().padStart(2, '0') + d.getDate().toString().padStart(2, '0') + d.getHours().toString().padStart(2, '0') + d.getMinutes().toString().padStart(2, '0') + d.getSeconds().toString().padStart(2, '0');\ncontext.get(\"timestamps\").push(timestamp);\nmsg.timestamps = context.get(\"timestamps\");\nmsg.newtimestamp = timestamp;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1120,"y":3440,"wires":[["8a4210abb1e0f3d0","53763c03b2b6aefd"]]},{"id":"5c85d23cecab7ae7","type":"inject","z":"34843a6c.50d986","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":560,"y":3480,"wires":[["0c2b4970293443e8"]]},{"id":"8a4210abb1e0f3d0","type":"change","z":"34843a6c.50d986","name":"","rules":[{"t":"set","p":"timestamps","pt":"flow","to":"timestamps","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1310,"y":3480,"wires":[[]]},{"id":"15f806a7e20ff379","type":"change","z":"34843a6c.50d986","name":"","rules":[{"t":"set","p":"timestamps","pt":"msg","to":"timestamps","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":3780,"wires":[["a2993d8364640c05"]]},{"id":"d2bc89831b31165f","type":"change","z":"34843a6c.50d986","name":"","rules":[{"t":"set","p":"timestamps","pt":"msg","to":"timestamps","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":3440,"wires":[["d5a6fd2dd32f3be0"]]},{"id":"6089532eb9cf0cce","type":"change","z":"34843a6c.50d986","name":"","rules":[{"t":"set","p":"timestamps","pt":"flow","to":"timestamps","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1090,"y":3780,"wires":[[]]},{"id":"101f560b2905ca57","type":"function","z":"34843a6c.50d986","name":"Remove recent values","func":"var timestamps = msg.timestamps || [];\nvar d = new Date();\nvar twoMinutesAgo = new Date(d.getTime() - 2 * 60 * 1000);\nvar filteredTimestamps = timestamps.filter(function (timestamp) {\n var timestampDate = new Date(timestamp.substring(0, 4), parseInt(timestamp.substring(4, 6)) - 1, timestamp.substring(6, 8), timestamp.substring(8, 10), timestamp.substring(10, 12), timestamp.substring(12, 14));\n return timestampDate < twoMinutesAgo;\n});\nvar recentTimestamps = timestamps.filter(function (timestamp) {\n var timestampDate = new Date(timestamp.substring(0, 4), parseInt(timestamp.substring(4, 6)) - 1, timestamp.substring(6, 8), timestamp.substring(8, 10), timestamp.substring(10, 12), timestamp.substring(12, 14));\n return timestampDate >= twoMinutesAgo;\n});\nmsg.timestamps = filteredTimestamps;\nmsg.recenttimestamps = recentTimestamps;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":960,"y":3620,"wires":[["f1e9c4b335bc0b65","14b0f5b371241891"]]},{"id":"a8604454369f6ce1","type":"inject","z":"34843a6c.50d986","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":560,"y":3660,"wires":[["5f03c04e857baac7"]]},{"id":"5f03c04e857baac7","type":"change","z":"34843a6c.50d986","name":"","rules":[{"t":"set","p":"timestamps","pt":"msg","to":"timestamps","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":3620,"wires":[["101f560b2905ca57"]]},{"id":"f1e9c4b335bc0b65","type":"change","z":"34843a6c.50d986","name":"","rules":[{"t":"set","p":"timestamps","pt":"flow","to":"timestamps","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":3660,"wires":[[]]},{"id":"14b0f5b371241891","type":"function","z":"34843a6c.50d986","name":"Split recenttimestamps","func":"var recentTimestamps = msg.recenttimestamps || [];\nfor (var i = 0; i < recentTimestamps.length; i++) {\n var msgOut = { payload: recentTimestamps[i] };\n node.send(msgOut);\n}\nreturn;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1180,"y":3620,"wires":[["220e4050698dfb89"]]},{"id":"220e4050698dfb89","type":"change","z":"34843a6c.50d986","name":"Define parameters to clear notifications","rules":[{"t":"set","p":"who","pt":"msg","to":"john&jane","tot":"str"},{"t":"set","p":"NotifyType","pt":"msg","to":"normal","tot":"str"},{"t":"set","p":"message","pt":"msg","to":"clear_notification","tot":"str"},{"t":"set","p":"tag","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1450,"y":3620,"wires":[["07d0eda70624aff6"]]},{"id":"659dbd93741102bf","type":"server-state-changed","z":"34843a6c.50d986","name":"Voordeur open","server":"5c29d263.09d2ac","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.voordeur_sensor","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"for":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":520,"y":3620,"wires":[["5f03c04e857baac7","c6fd93282e454ea8"],[]]},{"id":"0c2b4970293443e8","type":"gate","z":"34843a6c.50d986","name":"Block?","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":true,"x":750,"y":3440,"wires":[["d2bc89831b31165f"]]},{"id":"be0308fbfd1c967d","type":"change","z":"34843a6c.50d986","name":"unblock","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":3580,"wires":[["0c2b4970293443e8"]]},{"id":"c6fd93282e454ea8","type":"change","z":"34843a6c.50d986","name":"block","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"close","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":3580,"wires":[["0c2b4970293443e8","ef2f110953b9f1e7"]]},{"id":"ef2f110953b9f1e7","type":"trigger","z":"34843a6c.50d986","name":"Pause 5min","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"5","extend":true,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":850,"y":3580,"wires":[["be0308fbfd1c967d"]]},{"id":"65c02a7035839da5","type":"change","z":"34843a6c.50d986","name":"","rules":[{"t":"set","p":"timestamps","pt":"msg","to":"timestamps","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":3320,"wires":[["fc19e0d5c6d2786e"]]},{"id":"fc19e0d5c6d2786e","type":"function","z":"34843a6c.50d986","name":"AddTimestamp","func":"var timestamps = msg.timestamps || [];\ncontext.set(\"timestamps\", timestamps);\nvar d = new Date();\nvar timestamp = d.getFullYear().toString() + (d.getMonth() + 1).toString().padStart(2, '0') + d.getDate().toString().padStart(2, '0') + d.getHours().toString().padStart(2, '0') + d.getMinutes().toString().padStart(2, '0') + d.getSeconds().toString().padStart(2, '0');\ncontext.get(\"timestamps\").push(timestamp);\nmsg.timestamps = context.get(\"timestamps\");\nmsg.newtimestamp = timestamp;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":940,"y":3320,"wires":[["dec8447e270e4ce0","ffa4217716abc9c6"]]},{"id":"ffa4217716abc9c6","type":"change","z":"34843a6c.50d986","name":"","rules":[{"t":"set","p":"timestamps","pt":"flow","to":"timestamps","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1130,"y":3360,"wires":[[]]},{"id":"68ce9fc76cc5b7d9","type":"comment","z":"34843a6c.50d986","name":"Person detected: silent notify mobiles","info":"","x":590,"y":3400,"wires":[]},{"id":"381a55c5652c45f3","type":"comment","z":"34843a6c.50d986","name":"Front door opened: clear recent mobile notifcations (doorbell pressed + person detected) & 5 min block person detected notification on mobiles","info":"","x":910,"y":3540,"wires":[]},{"id":"502b7a886213a8b9","type":"comment","z":"34843a6c.50d986","name":"Daily clean up array of timestamps (remove old timestamps)","info":"","x":660,"y":3740,"wires":[]},{"id":"03c1f1ecf28cc7a5","type":"debug","z":"34843a6c.50d986","name":"Rest of the flow to sent the notification to your mobile","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1620,"y":3440,"wires":[]},{"id":"07d0eda70624aff6","type":"debug","z":"34843a6c.50d986","name":"Rest of the flow to sent the notification to your mobile","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1820,"y":3620,"wires":[]},{"id":"5c29d263.09d2ac","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]