Hikvision Video Doorbell PIR to OmniPro 2 zone


Here the only way to see the hardware PIR motion detector in the Hikvision doorbell is to utilize ONVIF.
Tinkering installed an ONVIF to MQTT plugin to detect motion from the Hikvision Doorbell.
Purchased an ESP-01S WiFi relay and installed Tasmota Firmware on it.
Using HA / Homeseer if then statement trigger the relay on the ESP-01S to close and trigger a zone on the OmniPro 2 panel.
Hardware required: (that I used)
1 - ESP01S WiFi module and Relay
Firmware additions:
1 - current version of Tasmota
Following adjustments:


  • Set module to Generic (18) (in module configuration and click save)
  • Set D3 GPIO0 as Relay1 (21) (in module configuration and click save)
  • Disable SerialLog (type seriallog 0 in the Tasmota console)
  • Add the following rules typing in the console:

 on System#Boot do Backlog Baudrate 9600; SerialSend5 0 endon
 on Power1#State=1 do SerialSend5 A00101A2 endon
 on Power1#State=0 do SerialSend5 A00100A1 endon

  • Enable the rule (type rule1 1 in the Tasmota console)



Enable relay commands:
cmd/Omni/HikVision_PIR/POWER ON


Setting pulse time so that the relay toggles on and off:
PulseTime 11
In HA the script is as follows
Name: Hikvision PIR
Trigger Type: MQTT
Topic: onvif2mqtt/Doorbell/motion
Payload: ON
Action Type: Call Service
Service: MQTT publish
Service Data
topic: Omni/HikVision_PIR/cmnd/POWER
payload: 'ON'


Last part here is powering up the relay with 5VDC.
Here using the OP2 12VDC power to a small bucky transformer.
Type used is same that I use for automotive smart phone charging.  I am just cutting off the usb side of it.


Next part is to shift the if then script from the HA / Homeseer instance to the Micro OpenWRT router.
Adding Python 3.x and Paho-MQTT client on it.
1 - expanded work space on the microrouter to 32Gb via a small USB stick.  Microrouter is installed between OP2 Ethernet port and Ethernet switch.  It has been working fine for a few years.
OpenWRT Using storage devices
OpenWRT Extroot configuration
2 - Paho-MQTT installation
package: python3-paho-mqtt

BusyBox v1.30.1 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 OpenWrt 19.07.5, r11257-5090152ae3

HAI:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 2.5M      2.5M         0 100% /rom
tmpfs                    29.3M    256.0K     29.1M   1% /tmp
/dev/sda1                28.1G     60.1M     26.6G   0% /overlay
overlayfs:/overlay       28.1G     60.1M     26.6G   0% /
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/mtdblock6            3.9M      1.8M      2.0M  47% /rwm

HAI:~# python3 --version
Python 3.7.9


1 - Installed Nano via command line:
opkg update
opkg install nano
2 - wrote following test script for MQTT client.

import paho.mqtt.client as mqtt #import the client1
client = mqtt.Client("P1") #create new instance
client.connect(broker_address) #connect to broker
3 - ran mqtt-explorer on Linux laptop
4 - executed script - working
5 - changed script to enable relay

import paho.mqtt.client as mqtt #import the client1
print("creating new instance")
client = mqtt.Client("P1") #create new instance
print("connecting to broker")
client.connect(broker_address) #connect to broker
print("Subscribing to topic","Omni/HikVision_PIR/cmnd/POWER")
print("Publishing message to topic","Omni/HikVision_PIR/cmnd/POWER")


To get motion to trigger the relay using the callback function in a python script.  
Here is a test script:    

import paho.mqtt.client as mqtt

def on_connect(client, userdata, flags, rc):  # The callback for when the client connects to the broker
    print("Connected with result code {0}".format(str(rc)))  # Print result of connection attempt
    client.subscribe("onvif2mqtt/Doorbell/motion")  # Subscribe to the topic "onvif2mqtt/Doorbell/motion, receive any messages published on it

def on_message(client, userdata, msg):  # The callback for when a PUBLISH message is received from the server.
    print("Message received-> " + msg.topic + " " + str(msg.payload))  # Print a received msg

client = mqtt.Client("onvif_mqtt_test")  # Create instance of client with client ID onvif_mqtt_test
client.on_connect = on_connect  # Define callback function for successful connection
client.on_message = on_message  # Define callback function for receipt of a message
client.connect('', 1883)
client.loop_forever()  # Start networking daemon

waved my hand in front of doorbell and see script working.

-HAI:/overlay/work# python3 callbacktest.pyConnected with result code 0
Message received-> onvif2mqtt/Doorbell/motion b'OFF'
Message received-> onvif2mqtt/Doorbell/motion b'ON'
Message received-> onvif2mqtt/Doorbell/motion b'OFF'
Message received-> onvif2mqtt/Doorbell/motion b'ON'
Message received-> onvif2mqtt/Doorbell/motion b'OFF'

Next pieces are on message received on publish relay message.


BTW before the above installed nano and sftp server using the Luci web interface.
CLI to install.
opkg update
opkg install nano
opkg install openssh-sftp-server


Rewrote script and tested it to work.  I am not seeing any errors when it is running.


import paho.mqtt.client as mqtt
broker_url = ""
broker_port = 1883


def on_connect(client, userdata, flags, rc):
    print("Connected With Result Code "+rc)

def on_message(client, userdata, message):

    global sensor
    print("Message Recieved: "+message.payload.decode())

client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message

client.connect(broker_url, broker_port)

client.subscribe("onvif2mqtt/Doorbell/motion", qos=1)

if sensor == "ON":

    client = mqtt.Client("P1") #create new instance
    client.connect(broker_address) #connect to broker

# client.publish("Omni/HikVision_PIR/cmnd/POWER","ON")#publish

    client.publish(topic="Omni/HikVision_PIR/cmnd/POWER", payload="ON", qos=1, retain=False)

sensor="OFF" # only want single publish




Updated script ....


import paho.mqtt.client as mqtt
MQTTv31 = 3
MQTTv311 = 4
MQTTv5 = 5
message = 'ON'
def on_connect(client,userdata, flags, rc):
    print("rc: " + str(rc))

def on_message(client, userdata, msg):
    global message
    print(msg.topic + " " + str(msg.qos) + " " + str(msg.payload))
    message = msg.payload

def on_publish(client, userdata, mid):
    print("mid: " + str(mid))

def on_subscribe(client, userdata, mid, granted_qos):
    print("Subscribed: " + str(mid) + " " + str(granted_qos))

def on_log(client, userdata, level, buf):

mqttc = mqtt.Client("petetest",protocol=MQTTv311)
# Assign event callbacks
mqttc.on_message = on_message
mqttc.on_connect = on_connect
mqttc.on_publish = on_publish
mqttc.on_subscribe = on_subscribe
# Connect
mqttc.connect("", 1883)
#mqttc.connect("", 1883)

# Continue the network loop


Starting the script at boot time:


To start the script at boot time:
1  - opkg update
2 - opkg install coreutils-nohup
3 - edit rc.local and insert
# Put your custom commands here that should be executed once# the system init finished. By default this file does nothing.

/usr/bin/nohup python3 /overlay/work/DB-MQTT-3.py &

exit 0


Testing the script by publishing via MQTT Explorer
onvif2mqtt/Doorbell/motion ON
and watching new defined doorbell motion zone on OmniPro 2 panel.

See the process via the OpenWrt GUI

1377 root python3 /overlay/work/DB-MQTT-3.py 0% 20%


Note I did fat finger the script some and fixed it yesterday:
Not working piece:

def on_connect(client,userdata, flags, rc):
    print("rc: " + str(rc))

Working piece: 
def on_connect(client,userdata, flags, rc):
    print("rc: " + str(rc))


Senior Member
Just bought a ezviz doorbell, which seems to be one of the many versions of the Hikvision dooorbell. I currently have a Ring Pro but got tired of paying over $108/year for Amazon to keep the video, plus it never worked that great anyway. 
I have NVR software built in my Synology Server, so planing on using that to store the video.  It has far more features than RING. I BELIEVE this doorbell is supported by it, but we shall see. I know Alexa supports it. Now I need to find some spotlight cameras to replace my RING spotlight cameras. I think ezviz makes one.


Have a read here (coauthored this document).
Hikvision Doorbell 101
I have the original Nelly Hikvision doorbell firmware updated to Hikvision software.  It is off the cloud and I am doing ONVIF, RTSP and JPG capture with it.
I have two NVRs connected to it.  Zoneminder and a Hikvision 8 POE port NVR. It is an ONVIF / RTSP.

I also have a Ring configuration Alarm monitoring in house #2.  I am monitoring it with HA and it works well these days. I am using a Ring to MQTT plugin for use with HA.

Getting tired of the Ring authentication stuff and their CS.
I removed / deregistered the EZViz Hikvision doorbell app and also have removed the app from my smartphones / tablets et al.