Dahua VTO custom integration

Yes, I see these events.
My question was moslty : do you suggest that I stop dahuavto2mqtt container to test that the integration catch all events ?

Both integration should work simultaneously without any problems, but for clean test, yes, I suggest you to stop dahuavto2mqtt container and make sure that your card is defined and opens the door then you pass it.

PS: I’m not sure why you use both integration (this and DahuaVTO2mqtt) because it’s more or less same and you can use just one.

Update: For catch all events I use this automation

Thank you for your answer.
I use the dahuavto2mqtt since ages to ring a bell. I plan to remove it as soon as I can catch the button event with the integration.

Here you can find the example.

Thank you, it is perfect, I get all events and nfc IDs.

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,
3 Likes

Thank you for sharing! Very nice configuration example!

1 Like

Just an update:
Thanks to the right help, the integration with the Dahua intercom was successful!

My hardware:
Outpost: DHI-VTO4202FB-P
Indoor station: VTH2421F-P

3 Likes

Hi,

I also have the DHI-VTO4202 with 5 doorbells.
The integration is working very well.

But sadly i cant differentiate between the 5 different buttons.
I want to ring the analog bell with a relay. But for this I first need to know which bell rings.
In the Log every button has the same output.

Thank you in advance.

Look at events

HAUI >> developer tools >> events >> listen to events

Subscribe to " * " and “start listening” for event generated by the button presses. Event may show difference between button.

1 Like

Hello, as suggested above you can use Developer Tools → Events and subscribe to dahua_vto events and you will see that every event has entity_id which you can use in order to diferinciate from which device it’s comes.

In this example event comes from sensor.dahua_vto:

event_type: dahua_vto
data:
  Action: Pulse
  Code: SIPRegisterResult
  Data:
    LocaleTime: "2023-02-01 02:05:49"
    Success: true
    UTC: 1635381449
  Index: 0
  entity_id: sensor.dahua_vto
1 Like

I have been playing a little to be able to communicate from a Dahua VTO to the home assistant with the Asterisk addon and the SIP card, but no luck, at the end it was more a hassle that a good solution.
So at the end, using this integration thanks a lot @myhomeiot I’m able at least to open the door and also send notifications in case I’m away to control the VTO from the Dahua App.

For the ones that are interested on somehow use a tablet as a VTH, what I finally did is two things:

  1. Create a button that opens the Dahua App for tablets from the HA, and after a few minutes go back to HA app
  2. Create an automation that in case of call from the VTO open the app for a few minutes, send a message to chromecast and notify my mobile, after a few minutes, the Dahua App will close and go back to the HA in the tablet

This is how it looks like:

If anyone is interesed on the automation let me know and I will post some yaml configs
With that, the tablet and the VTH can be used to answer the door, and no need of addons or to config the VTO/VTH
I have been using it for a couple of weeks, and so far so good :smiley:

3 Likes

Is it possible to switch the IR on at night and leave it on? By default it only comes on for a few seconds when the doorbell is pressed. Thanks.

You can try this and this, if it’s works for you than you can think how to automate it using this integration.

Hy,
can someone help me?
I search a cheap dahua video doorbell with wifi.
Is working wit this integration the VTO1301R-W?

Thanks for the reply. The setconfig command returns ok, but doesn’t do anything. And in the DMSS app I don’t get the light icon unfortunately.

Should works, because according datasheet it’s can be controlled from application.

1 Like

Surelly I’m interessed on how did you made the app open, and also close the app.
What tablet are you using?
Thanks!

Sure @zejulio, you can invoke other apps from notifications, in my case I have a android tablet (Kindle Fire 10 HD), to make it work create an script with the following:

alias: Open DMSS
sequence:
  - service: notify.mobile_app_kftrwi
    data:
      message: command_launch_app
      data:
        package_name: com.mm.android.DMSSHD
  - delay:
      hours: 0
      minutes: 2
      seconds: 0
      milliseconds: 0
  - service: notify.mobile_app_kftrwi
    data:
      message: command_webview
      data:
        command: /lovelace
mode: single
icon: mdi:doorbell-video

You need the DMSS HD app installed on the tablet, the first notification open the app, and after a couple of minutes it goes back to Home Assistant App.
:smiley:

1 Like

Hello,

Many thanks!

How do you manage to open the DMSS app directly to the VTO screen? I need to open DMSS then select VTO from list, then the video start…
Also I try to register the notifications for the VTO no DMSS and it say’s failure…

Thanks,

Julio Silva