dbell HTTP hook
Brief:
dbell aims to be a developer friendly door bell and understands one of the appeals of a video doorbell is to be able to connect it to NVR solutions such as ZoneMinder, BlueIris or automation solutions such as HomeAssistant. For developers dbell offers a way to be notified when the doorbell button is pressed. This is often useful as a “trigger” to execute custom actions such as:
- Turn on porch lights when the doorbell is pressed (via HomeAssistant)
- Start video recording when the doorbell is pressed, or start face recognition (via ZoneMinder’s machine learning hooks, for example)
- And many more
Configuration:
As of now, the HTTP hook is overloaded with the FTP server information. In future, this may be changed to allow both to work in parallel. You can setup the HTTP hook either via the web interface or the dbell app:
Via the web interface:
- Navigate to yourdbellip:81 and login
- Go to Alarm Service Settings->FTP service settings
- In the FTP server input, enter a well formed HTTP URL like http://192.168.1.21:5000/dbell . This will be the URL of your server that will receive notifications. Note that it is expected that you have a web service running on this IP/port/URL to receive notifications
- Tap on “Set up” button
- Restart the dbell (via Users & Device manage->Maintain->Reboot Device)
- One the dbell comes back up, validate that the settings are still there to make sure they were saved
Via the app:
- Go to dbell Settings (4-square icon)
- Storage & Cloud
- FTP
- In the FTP server input, enter a well formed HTTP URL like http://192.168.1.21:5000/dbell . This will be the URL of your server that will receive notifications. Note that it is expected that you have a web service running on this IP/port/URL to receive notifications
- Tap on “Save” button
- Restart the dbell (via Settings -> Restart)
- One the dbell comes back up, validate that the settings are still there to make sure they were saved
Usage:
- Press the dbell button (make sure it is pressed for more than 0.3 seconds)
- The dbell will attempt to send an HTTP POST to your server
Message Format:
The HTTP POST that dbell sends looks like this:
POST /dbell HTTP/1.1
User-Agent: curl/7.21.0 (arm-unknown-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8g zlib/1.2.11
Host: 192.168.1.21:5000
Accept: */*
Content-Length: 79
Content-Type: application/json
{"deviceid":"HSL-XXX-XXXX", "alias":"Home doorbell", "action": "HTTP Hook"}
Where:
- deviceid is the unique device serial #/ID assigned to the device
- alias is the name you have given to that doorbell
Notes:
- dbell does not require a persistent connection to your server. It initiates an HTTP connection when the bell is pressed and terminates it after the HTTP message is sent. Therefore, even if the server goes down in-between, it will not affect future messages
- dbell does not queue or retransmit unsent messages
- Self signed certificates are not supported. Please use HTTP or signed HTTPS certificates on your server as needed
- If the bell is pressed for < 0.3 seconds (approximately), dbell may not send a message to the server. The door chime however will ring.
Sample server
We assume most developers will know how to write a sample server that can be used to intercept the POST message for further action. As an example, here is a simple proof of concept python/flask server that receives the POST message. If you are also using the Machine Learning hooks for ZoneMinder via the Event Server, this will result in face recognition also being triggered.
Alternately, you can, in your callback, simply extract a snapshot of the image and invoke face detection on it manually (The EventServer detection script detect.py can be called manually as well with a filename). To get a snapshot from dbell, the URL is http://yourdbellip:81/snapshot.cgi?loginuse=username&loginpas=password
from flask import Flask, request
import requests
app = Flask(__name__)
def start_recording(payload):
# not doing much with payload here, but you can use it if you
# plan to use zmtrigger to comment the notes section of the event
token = 'add your ZM API token here'
monitor_id = 1 # change to monitor id to alarm
server_url= 'https://server/zm'# base url of ZM
url = '{}/api/monitors/alarm/id:{}/command.json?token={}'.format(server_url, monitor_id, token)
requests.post(url)
return
@app.route('/dbell', methods=['POST'])
def bell_pressed():
payload = request.get_json()
start_recording(payload)
return ('Bell pressed')
app.run(host='0.0.0.0')
Please note, we do not provide any support for webhook.
This is advanced level self-help feature designed for advanced user/developers.
Comments
0 comments
Please sign in to leave a comment.