Hi, this is the setup I’m using for my system if anyone finds it useful.
I’m using the VIP Vision INTIPRDSDB and INTIPMONDW, which are basically rebranded versions of the Dahua VTO2111D and VTH5221D. They work perfectly with this integration.
They were acting weird until I updated the firmware on them to 4.300.0000006.0.T,build:2019-03-20
first though.
As well as setting up this integration I added the intercom camera using the Generic Camera integration using the following URLs and digest auth with the same admin and the password for the intercom.
I used Connect to Dahua cameras to figure out which camera urls to use, and ended up using:
http://<ip_address>/cgi-bin/snapshot.cgi?1
rtsp://admin:<password>@<ip_address>:554/cam/realmonitor?channel=1&subtype=1
This gives the sub/second stream, set "subtype=0"
instead for the main stream.
Sensors and locks defined in configuration.yaml:
The main things that will need changing are:
- The VTO name, I named mine “Intercom” so replace the
"sensor.intercom"
with yours
- Auto_off times depending on your settings on the intercom
- Access card IDs and names
- Remove the entries for the second gate if you only have one connected
- And potentially the names of all the created entities
(the unique_ids probably should all be random UUIDs, but I made these before I knew that (UUIDs can be generated in the cog menu of the File Editor addon))
template:
# Tamper sensor for the camera being covered
- trigger:
platform: event
event_type: dahua_vto
event_data:
Code: VideoBlind
binary_sensor:
- name: VTO Camera Covered
unique_id: "vto_camera_covered"
state: "{{ trigger.event.data.Action | string == 'Start' }}"
device_class: tamper
# Sensors for the gate connected to the first intercom relay
- trigger:
platform: event
event_type: dahua_vto
event_data:
Code: AccessControl
Index: 0
binary_sensor:
# State of the relay
# Use the timer set in the intercom web interface for the unlock time as the auto_off time
- name: Front Gate State
unique_id: "front_gate_state"
auto_off: 5
state: >
{{ trigger.event.data.Data.Name | string == "OpenDoor"
and
trigger.event.data.Data.Status | int == 1 }}
device_class: lock
sensor:
# The last access method used to unlock the gate
# The state will be set according to which one of the following trigged the unlock:
# Access card ID
# Short_number value of the dahua_vto.open_door service (HA is from the template lock set below, HA_Notif is from an automation)
# Room number of the Dahua tablet (9901)
# The attributes:
# Successful unlock?
# Which method was used to unlock (Mine only supports Access Card or by Network)
# The full event data
- name: Front Gate Access
unique_id: "front_gate_access"
state: >
{% if trigger.event.data.Data.Method | int == 1 %}
{% set cards = {
"12345671": "Card 1",
"12345672": "Card 2",
"12345673": "Card 3",
"12345674": "Card 4",
} %}
{% if trigger.event.data.Data.CardNo in cards %}
{{ cards[trigger.event.data.Data.CardNo] }}
{% else %}
Unrecognised card: {{ trigger.event.data.Data.CardNo }}
{% endif %}
{% elif trigger.event.data.Data.UserID | string == "HA" %}
Home Assistant
{% elif trigger.event.data.Data.UserID | string == "HA_Notif" %}
Notification
{% elif trigger.event.data.Data.UserID | string == "9901" %}
Intercom Tablet
{% else %}
Other Unlock: {{ trigger.event.data.Data.Method | int }}
{% endif %}
attributes:
Successful: "{{ trigger.event.data.Data.Status | int == 1 }}"
Method: >
{% if trigger.event.data.Data.Method | int == 1 %}
Card
{% elif trigger.event.data.Data.Method | int == 4 %}
Remote
{% else %}
Other: {{ trigger.event.data.Data.Method | int }}
{% endif %}
Data: "{{ trigger.event.data }}"
# Sensors for the gate connected to the second intercom relay
# Use the timer set in the intercom web interface for the unlock time as the auto_off time
- trigger:
platform: event
event_type: dahua_vto
event_data:
Code: AccessControl
Index: 1
binary_sensor:
- name: Car Gate State
unique_id: "car_gate_state"
auto_off: 30
state: >
{{ trigger.event.data.Data.Name | string == "OpenDoor"
and
trigger.event.data.Data.Status | int == 1 }}
# Whether the doorbell is ringing
# Used to trigger the doorbell automation
# Use the ringing time from the intercom as the auto_off time
- trigger:
platform: event
event_type: dahua_vto
event_data:
Code: BackKeyLight
binary_sensor:
- name: Doorbell Ringing
unique_id: "doorbell_ringing"
auto_off: 60
state: >
{% if trigger.event.data.Data.State | int == 1 %}
on
{% elif trigger.event.data.Data.State | int == 0 %}
off
{% else %}
{{ states("binary_sensor.doorbell_ringing") }}
{% endif %}
device_class: sound
# Uses the above gate sensors to define locks that allow opening the gates
# The short_number sets the UserID for the unlock event
lock:
# Gate connected to relay 1
- platform: template
name: Front Gate
unique_id: "front_gate"
value_template: "{{ not is_state('binary_sensor.front_gate_state', 'on') }}"
lock:
unlock:
service: dahua_vto.open_door
data_template:
entity_id: sensor.intercom
channel: 1
short_number: HA
# Gate connected to relay 2
- platform: template
name: Car Gate
unique_id: "car_gate"
value_template: "{{ not is_state('binary_sensor.car_gate_state', 'on') }}"
lock:
unlock:
service: dahua_vto.open_door
data:
entity_id: sensor.intercom
channel: 2
short_number: HA
If I had a magnetic sensor (Dahua VTO custom integration - #115 by myhomeiot) I’d probably combine it with the relay for the status of the lock.
Notification automations:
The sensor, camera, intercom, and notify entity names will need changing
# Sends a notification when an invalid card is used on the intercom.
# I assume this would also work similarly with an invalid keypad code if supported by the intercom.
alias: Notify Dahua VTO Invalid Card
description: ""
trigger:
- platform: state
entity_id:
- sensor.front_gate_access
attribute: Successful
to: false
condition: []
action:
- service: notify.notify_all_phones
data:
message: >-
Invalid card: "{{ trigger.to_state.attributes.Data.Data.CardNo }}" used
on intercom
data:
push:
interruption-level: time-sensitive
mode: single
# Sends a notification to the notification group I created when the intercom's button is pressed.
# It allows the camera to be shown when you long press on the notification (on iOS, probably similar on Android)
# It waits for the CANCEL_CALL action for the time the intercom rings for then cancels the call if received in that time.
# There is then a separate automation to receive the OPEN_GATE action which opens the gate and cancels the call.
# They could be merged into the same automation, but I wanted the open gate action to work at any time and I didn't really want it waiting in this automation forever.
alias: Notify Dahua VTO Doorbell
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.doorbell_ringing
to: "on"
from: "off"
condition: []
action:
- service: notify.notify_all_phones
data:
title: Someone's at the gate
message: Open to see camera
data:
tag: intercom
entity_id: camera.intercom_sub
actions:
- action: OPEN_GATE
title: Open gate
- action: CANCEL_CALL
title: Cancel Call
push:
interruption-level: time-sensitive
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: CANCEL_CALL
continue_on_timeout: false
timeout:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- service: dahua_vto.send_command
data:
entity_id: sensor.intercom
method: console.runCmd
params:
command: hc
event: true
alias: "Dahua VTO: Send command: Cancel Call"
mode: restart
# Listens for the notification action, opening the gate and stopping the ringing
alias: Notify_Action Event Intercom Open Gate
description: ""
trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: OPEN_GATE
context: {}
condition: []
action:
- service: dahua_vto.open_door
data:
entity_id: sensor.intercom
channel: 1
short_number: HA_Notif
- service: dahua_vto.send_command
data:
entity_id: sensor.intercom
method: console.runCmd
params:
command: hc
event: true
mode: single
And here’s a list of the useful identifying parts of events that are generated for various things:
VTO Events:
"event_type": "dahua_vto"
Valid card used to unlock door:
Card swiped:
"Code": "DoorCard",
"Data": {
"Number": "1234567c",
Card successfully used:
"Code": "AccessControl",
"Data": {
"CardNo": "1234567c",
"Name": "OpenDoor",
"Status": 1,
Door unlocked:
"Code": "BackKeyLight",
"Data": {
"State": 8,
Invalid card attempt to unlock door:
Card swiped:
"Code": "DoorCard",
"Data": {
"Number": "a8765432",
Card unsuccessfully used:
"Code": "AccessControl",
"Data": {
"CardNo": "a8765432",
"Name": "OpenDoor",
"Status": 0,
Failed door unlocked:
"Code": "BackKeyLight",
"Data": {
"State": 9,
Camera Covered:
Beginning:
"Action": "Start",
"Code": "VideoBlind",
End:
"Action": "Stop",
"Code": "VideoBlind",
Doorbell Rang:
Button pressed:
"Code": "BackKeyLight",
"Data": {
"State": 1,
Ringing:
"Code": "BackKeyLight",
"Data": {
"State": 2,
Call not answered:
Call timeout:
"Code": "BackKeyLight",
"Data": {
"State": 6,
> 8 seconds
Back to normal state:
"Code": "BackKeyLight",
"Data": {
"State": 0,
Call answered by VTH:
Call answered:
"Code": "BackKeyLight",
"Data": {
"State": 5,
> After call
Back to normal state:
"Code": "BackKeyLight",
"Data": {
"State": 0,
Ringing cancelled by notification:
Command response:
'result': True,
'method': 'console.runCmd',
'entity_id': 'sensor.intercom'
Back to normal state:
"Code": "BackKeyLight",
"Data": {
"State": 0,
Ringing cancelled by VTH:
"Code": "BackKeyLight",
"Data": {
"State": 0,