Dahua VTO custom integration

Hi all, Thanks so much for this, just what I needed!

Question - is it possible to keep the lock mechanism open for a defined period rather then the 1-2 seconds it does by default when using the accessControl.openDoor method?

I am trying to open my gate at 7am and close it at 5pm (by keeping the unlock function open for 10 hours).

Thanks in advance!

JDFB

AFAIK

Unlock command doesn’t have this parameter and only one place where you can define Unlock Period it’s VTO admin GUI.

Ahh ok, thanks for that!

I will look at putting a relay in line to bypass the VTO and operate the lock directly.

Cheers

Can someone help me? Integration works, but I would like to use it to control the light switch. This is to work on the principle, someone presses the intercom button, the light comes on.

If press the button it’s a door bell ring, you can do it like this:

- alias: Dahua VTO Ring
  mode: queued
  trigger:
    - platform: event
      event_type: dahua_vto
      event_data:
        Code: BackKeyLight
  action:
    - choose:
        - conditions: >
            {{ trigger.event.data.Data.State | int in [0, 1, 2, 5, 6] }}
          sequence:
            - service: homeassistant.turn_on
              entity_id: light.entrance

This is also what I have set up, but only notifications such as below appear. How to control this to some other device?

All this notification comes from calls to persistent_notification.create, check your configuration and replace call to this service with something reasonable.

Can you show me how to do it? Sorry, but I’m a beginner with Home Assistant

myhomeiot asked me to share my FreePBX setup here for the Dahua.

I have a setup where the VTO Dials a ring group, which calls all my devices. When the first device answers, the others will stop ringing. I can press # open the lock (in my case this opens a drive in gate). This allows me to use any SIP client, so I can answer the door from my PC. You could also potentially use this to call over the standard PSTN network - but I have never tried that.

First off, FreePBX does not work in docker so don’t waste your time trying like I did.

I used libvirt/kvm to install the FreePBX operating system. I used macvtap to give it a dedicated IP address on my LAN.

Once you’ve installed, head to the FreePBX admin panel and go to applications > extensions and create an extension with number 8001. Note the “Secret”, this is the password to use in SIP clients.

Create another extension with number 1001. Again note the secret. Set up a SIP client (I used linphone) and connect to [email protected]. Make sure that’s working and the light goes green.

Next head to applications > ring groups and add a ring group. Give it number 9901. In extension list enter 1001. Don’t need to change anything else.

On the Dahua VTO, my SIP settings are:

SIP Server Enable: Unchecked.
Server Type: ThirdParty
IP address: IP of FreePBX Server
Port: 5060
Username: 8001, Enable unchecked
Password: Extension password

At this point things should work, if you want # to open the lock support, read on.

Create /etc/asterisk/extensions_custom.conf and change the two instances of CHANGEME (The first is the password you’d when visiting the Dahuas web panel)

[macro-gateopen]
exten => s,1,System(curl --digest -v -u admin:CHANGEME "http://CHANGEME/cgi-bin/accessControl.cgi?action=openDoor&UserID=101&Type=Remote&channel=1")

;end [macro-gateopen]

Create /etc/asterisk/features_applicationmap_custom.conf

opengate => #,caller,macro,gateopen

Create /etc/asterisk/globals_custom.conf

DYNAMIC_FEATURES = opengate

After restarting FreePBX you should be good to go. Note that this is a slightly hacky solution, since # will work on any call made through FreePBX, and either side of a call will be able to open the gate. So it’s only a good solution if you use FreePBX for your Dahua and nothing else, which in my case, I do.

I’m on home assistant discord if anyone has any questions about it :slight_smile:

5 Likes

@Azelphur Thanks a lot!

With DAHUA VTO integration I found a way to pick up Sensor Status from relays from Dahua cameras and access controls
I use cameras with face recognition technology
When the camera recognizes the face or the access controller recognizes the finger then open the relay and unlock the door for 7 seconds
And in Home Assistant I get the status that the relay is open.
Then I can with the status entity dissarm home alarm system or other cunfigurations.

image image





To sensors.yaml - or configuration.yaml add sensors
######################## Door ASI1212D relay status ############################

################### Face cam IPC-HDBW7442H-ZFR relay status ####################

################# DHI-VTO7541G with face recognizer and fingerprint #################

  • platform: dahua_vto
    name: Dahua VTO
    host: 192.168.0.250
    username: !secret vto_user
    password: !secret vto_pass
    port: 8888
    scan_interval: 5

  • platform: command_line
    name: VTO DOOR STATUS
    command: “/usr/bin/curl --digest --user admin:password ‘http://192.168.0.250:8888/cgi-bin/accessControl.cgi?action=getDoorStatus&channel=1’”
    scan_interval: 01
    ################# DHI-VTO7541G Unlock swith #################
    in configuration.yaml
    lock:

    • platform: template
      name: Door Lock
      value_template: “{{ not is_state(‘timer.door_lock’, ‘active’) }}”
      lock:
      unlock:
      • service: dahua_vto.open_door
        data_template:
        entity_id: sensor.dahua_vto
        channel: 1
        short_number: HA

for lovelace configuration:
type: custom:button-card
icon: mdi:doorbell-video
name: Door
tap_action:
action: call-service
service: dahua_vto.open_door
service_data:
entity_id: sensor.dahua_vto
channel: 1
short_number: HA
styles:
card:
- font-size: 12px
- font-weight: bold
color: green
image

Maybe someone picked up status information through MQTT?

Hi all,
One question but not related to HA.
I’m receiving again and again the famous tamper alarm. I’m also seeing that the camera connection is lost due to the device was re-initialized automatically. I need to define the user, password and email. I didn’t change anything and there isn’t any blackout.

Have you ever had the same problem?

Hello, I have few questions maybe You could help me. I have VTO with 2 rooms and 2 unlock buttons (gate and wicket). Is possible to have all functionalities from DMSS? The most I need

  1. Open 2 button - gate and wicket
  2. Camera
  3. Receive messages on phone

Could some help me and paste full yaml code? I’m new with HA and trying to learn, don’t know how to deal with this code. Thanks

Anyone have any idea how to end a call from Home assistant. I’d like the ringing to stop when my smart lock unlocks.

Check project readme, Cancel VTO Call example

Hello,

Using this project you can unlock gate and wicket, camera you can connect to Home Assistant using generic RTSP integration, messages on the phone you can receive using Telegram or another similar Home Assistant integration.

Unfortunattely the Home Assistant yaml will be very specific for your needs, in this project readme you an find some yaml snippets for unlock VTO, ect.

Try to find Home Assistant Telegram channels where other peoples can answer your questions, point to specific examples and help you learning Home Assistant, it’s will take some time but for sure you will catch it’s quick enough.

Thanks, it stops ringing now when the lock is unlocked.

There is a binary sensor that reports pressing a button in the Dahua intercom. If I pick up the call on my phone, its status changes from on to off. If I don’t answer, it’s on all the time. What to do to make it change its state from on to off, e.g. after 30 seconds?245638801_5107768815918751_4436862777588187410_n

Hello,

This integration doesn’t have doorbell sensor. I’m not sure how you program this sensor, but you can do something similar using Home Assistant timer, as example:

timer:
  doorbell:
    name: Doorbell
    icon: mdi:timer

binary_sensor:
  - platform: template
    sensors:
      doorbell:
        friendly_name: Doorbell
        icon_template: mdi:doorbell-video
        value_template: "{{ is_state('timer.doorbell', 'active') }}"

automation:
  - alias: Dahua VTO Doorbell
    mode: queued
    trigger:
      - platform: event
        event_type: dahua_vto
        event_data:
          Code: BackKeyLight
    action:
      - choose:
          - conditions: >
              {{ trigger.event.data.Data.State | int in [1, 2] }}
            sequence:
              - service: timer.start
                data:
                  entity_id: timer.doorbell
                  duration: 00:00:30
          - conditions: >
              {{ trigger.event.data.Data.State | int in [5] }}
            sequence:
              - service: timer.cancel
                data:
                  entity_id: timer.doorbell
1 Like

if I unlocked the door using the HomeKit, the status is stuck on unlocking .Is there anyway to set the status as unlocked in HomeKit?