Dahua VTO custom integration

Hi @myhomeiot, i am not sure whats the cause, but over time the automation for ringing doorbell would stop working by itself. I cant get any more detailed than these… I think the fix would be restarting home assistant and the doorbell, though I’m not sure, since usually after outage it would be working again.
dahua firmware is the latest, just updated like 2-3 weeks ago.

Speaker is working , the other automation with speaker is still working, the speaker part for the automation is also working when tested.

alias: Dahua-VTO
description: ""
trigger:
  - platform: event
    event_type: dahua_vto
    event_data:
      Code: BackKeyLight
condition:
  - condition: template
    value_template: "{{ trigger.event.data.Data.State | int in [1, 2] }}"
action:
  - service: media_player.play_media
    target:
      entity_id: media_player.vlc_telnet
    data:
      media_content_id: media-source://media_source/media/Doorbell.mp3
      media_content_type: audio/mpeg
    metadata:
      title: Doorbell.mp3
      thumbnail: null
      media_class: music
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://media_source
        - media_content_type: ""
          media_content_id: media-source://media_source/media/.
mode: restart


Everything look good, to be sure what happening you need to check which value has trigger.event.data.Data.State when automation is triggered, maybe something goes wrong with this.

Easy way to check, when this start happening go to Developer Tools → Events and start listen for dahua_vto events, press door bell and check which events you receives.

PS: In Dahua VTO web interface check what you have in System → Auto maintenance settings, if you have Never, set some day and time when it’s restarts for maintenance, maybe this helps.

Sorry for the super late reply, problem is sometimes its working sometimes its not,
just this morning it stops working again. but strangely after pressing twice it works again, it fires alot of events, so i’m trying to narrow down the events

Is this enough log to trace the cause?

Yes, VTO produce lot of events it’s normal. You should look only for BackKeyLight events and it’s State field. List of states with descriptions you can find here.

event_type: dahua_vto
data:
  Action: Pulse
  Code: BackKeyLight
  Data:
    LocaleTime: "2023-07-17 09:24:00"
    State: 0
    UTC: 1689560640

Hi
Is it possible to see which user opened the door in the unlock event so I can be notified of a specific user?
Sorry if this has been covered but I couldn’t find it.
Thanks

At least with mine, I can use the AccessControl events and if event.data.Data.Method == 1 then a card/nfc tag was used and event.data.Data.CardNo gives the ID of the card which can be matched with the IDs from the intercom’s web interface and then used to identify a person. There’s an example of how I use it in my (rather long) config here, around the middle of the first code block:

Hi
Thanks for your info. Yes I saw your post but I only use password to access. I have a rental property and basically would like to know when the cleaner is there. She has a code to enter so just want a notification on the event of her code… Would AccessControl events show a password ID? I have automations to listen to the dahua events but I haven’t seen AccessControl appearing in the logs…

This is what i see when a passcode is used to open the gate. Is there a way I can identify which passcode is used?

{'Action': 'Pulse', 'Code': 'AccessControl', 'Data': {'CardNo': '', 'CardType': None, 
'LocaleTime': '2023-08-05 18:55:37', 'Method': 0, 'Name': 'OpenDoor', 'Password': '', 
'ReaderID': '1', 'RecNo': 183, 'SnapURL': '', 'Status': 1, 'Type': 'Entry', 'UTC': 1691254537.0, 
'UserID': '8001'}, 'Index': 0, 'entity_id': 'sensor.front_gate'}

You have 'UserID': '8001' is it possible to have few passcode for one user? Or you can match passcode with this UserID?

I looked into that and it seems the userid refers to the VTO.

There are 8 passwords set and the one being used is number 4 in the list.

As you have password field empty in event from VTO probably it’s no way to get it :frowning:
Not sure but maybe the easiest way will be to create dedicated VTO UserId for cleaner with one password.

Good idea I will try that thanks.

Hi folks. Sorry to both you with this. I have the integration installed, with configuration.yaml updated. In HA I can now see sensor.front_gate, just reporting an OK state.

I’m now trying to understand where I add the examples provided. I want to add a capability to receive doorbell notifications, as well as trigger the door unlock and close operations (opening and closing the gate). Where do I add these additional examples - which file?

If you are not familiar with Home Assistant YAML configuration, it’s can be complicated.
Look into this post maybe this integration will do a work. If not, and you want to use this integration than look into youtube videos for Home Assistant YAML configuration lessons. YAML configuration much more powerful than regular GUI configuration specially for automation and extra sensors.

Fair response. I’ve added the timer: and lock: objects to configurartion.yaml, and now them surfaced as entities in HA. Can someone help me understand the relationship between timer: and lock:. I can see the latter is a template, dependant on the timer. But I don’t understand the role of the timer in relation to the lock call??

Hi
I’m not sure how to do this can you explain please?

Hi there!

Is there a way to get the lock status (locked/unlocked)?
For example, after clicking the button near the gate or using HA, DMSS, VTH or any other method, can I retrieve the sensor status?

I do not have any magnetic sensor, I do not want to check door status, just lock status after clicking button to open gate.

Sorry, could you explain this to me better? I don’t know where to add the switch.

I have recently discovered this world and I want to learn
I would like to add gate opening on homekit…

I thank you in advance

1 Like

Hello good. I have the entire surveillance system with Dahua, so I see the cameras without problems since I have a recorder and integrated with Dahua. I’m just missing that precious button that you have on the right… So when they knock it notifies me on my mobile and I can open the door or not… If you can give me a hand. Thanks in advance

Because Dahua VTO allow only unlock call and has configurable unlock period (see picture) I use a timer for count this unlock period. In readme example you can see that timer starts for 2 seconds as in configuration from the screen.

        - conditions: >
            {{ trigger.event.data.Data.State | int == 8 }}
          sequence:
            - service: timer.start
              data:
                entity_id: timer.door_lock
                duration: 00:00:02 # VTO Unlock Period