Dahua VTO custom integration

Thanks for sharing, with this other camera integration works great for my propose, get notifications when some rings the bell in HA

Good morning community, i have a vto2000 and added it to my HA. Everything seems to work well. I get a notification when the doorbell is rang and i can open the door via button. What i have problems with is the following:

I Added the lock to homekit via homekit bridge. I can also open the door via Homekit with a slider button. But after the door opens, it doesn´t move back to “closed”, it keeps saying “opening” until i manually slide it back to closed.

Is there anyway Homekit can do this automatically?

Thanks in advance!

Should works ok if you are using example from readme.
This example uses timer.door_lock, be sure that you catch unlock event (code 8) and start the timer like it’s shows here.

You can also try to start the timer in the lock after calling open_door command:

timer:
  door_lock:
    name: Door Lock
    icon: mdi:timer

lock:
  - platform: template
    name: Door Lock
    value_template: "{{ not is_state('timer.door_lock', 'active') }}"
    optimistic: false
    lock:
    unlock:
      - service: dahua_vto.open_door
        data_template:
          entity_id: sensor.dahua_vto
          channel: 1
          short_number: HA
      - service: timer.start
        data:
          entity_id: timer.door_lock
          duration: 00:00:02 # VTO Unlock Period
1 Like

Hello myhomeiot, the timer.start with duration worked perfect! Thank you so much!

Hi guys,

Quick question from a noob on this topic :smiley:
I live in a building where each apartment has VTH5221 that’s connected to main intercom downstairs via UTP cable, which also provides power(PoE).
Today I found out that I can access the ‘secret’ many on my VTH and connect it to my home wifi network, which I did.
Now, I came up to this thread wondering if I can integrate this device in my HA, but no luck so far.

Is this possible to achieve in my case at all?

Yes, you can try to define VTH connection at config:

sensor:
  - platform: dahua_vto
    name: Dahua VTH
    host: 192.168.1.100 # IP address of VTH
    username: admin # For VTH usually admin
    password: 112233 # Same password as you use to get into VTH settings usually 6 digits
    scan_interval: 30

Than you can use this automation’s to get events from VTH.
See for received events and maybe you can find something useful. Sure you should get call information when someone rings you from VTO.

Thanks. Seems like the connection to my VTH works, I can see events when I add that automation.
But opening the door doesn’t seem to work. This is what I get from debug:


2024-04-13 12:54:50.141 DEBUG (MainThread) [custom_components.dahua_vto.sensor] <<< {"id":138,"params":{"timeout":60},"result":true,"session":25351993}

2024-04-13 12:55:11.632 DEBUG (MainThread) [custom_components.dahua_vto.sensor] >>> {"method":"accessControl.factory.instance","params":{"channel":0},"id":139,"session":25351993}

2024-04-13 12:55:11.952 DEBUG (MainThread) [custom_components.dahua_vto.sensor] <<< {"error":{"code":268894210,"message":"Method not found!"},"id":139,"result":false,"session":25351993}

Hi,

On the VTO, we can report state of the door, when activated, we got the event above :

event_type: dahua_vto
data:
Action: Pulse
Code: DoorStatus
Data:
LocaleTime: “2024-04-09 20:56:05”
RealUTC: 1712688965
Relay: true
Status: Close
UTC: 1712692565
Index: 0
entity_id: sensor.dahua_vto

And

event_type: dahua_vto
data:
Action: Pulse
Code: DoorStatus
Data:
DoorIndex: 0
LocaleTime: “2024-04-13 11:01:53”
RealUTC: 1712998913
Status: Open
UTC: 1713002513
Index: 0
entity_id: sensor.dahua_vto

That intressting because it offer the posibility to report the state of an entity from HA to VTH.

I don’t use the lock inside the VTO so y would like to report the state of my gate in place of.

But i don’t find the commande to send, I achied it with the alarm thanks to you.

Have someone an idea ?
Thanks
Thomas

VTH doesn’t have command for opening door like VTO has. But you can try to issue console od command to open door. In order to play with your VTH and find and test what you can do with it you can use this tool. Here the list of commands for VTH from mcw0/DahuaConsole tool and my VTH, but at my VTH the od command doesn’t works :frowning:.

If you find working command and test it with DahuaConsole than you can issue it from integration:

# Send VTH Command od
service: dahua_vto.send_command
data:
  entity_id: sensor.dahua_vth
  method: console.runCmd
  params: {'command': 'od'}
  event: false

Hi, I have set up this integration and now I’m trying to use this command to stop audio from playing. Could you please show how sensor.dahua_vth is configured in configuration.yaml? VTO is all good but I fail at adding the VTH to HA.

Thank you in advance!

Sorry, missed the post you discribed how to set up VTH.
It tried that but it doesn’t work for me.

This is what I have in the configuration.yaml. I didn’t change any user or password in VTO or VTH. On VTH directly this default password is accepted. For user I don’t know there isn’t a username specified anywhere in VTH. But in HA I get this error:

sensor:
  - platform: dahua_vto
    name: GoliathVTO
    host: 192.168.178.110
    username: admin
    password: !secret vto_password
    scan_interval: 30
  - platform: dahua_vto
    name: GoliathVTH
    host: 192.168.178.109
    username: admin
    password: 123456
    scan_interval: 30


2024-04-25 14:52:14.767 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorSocketTransport._call_connection_lost(None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1181, in _call_connection_lost
    super()._call_connection_lost(exc)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 901, in _call_connection_lost
    self._protocol.connection_lost(exc)
  File "/config/custom_components/dahua_vto/sensor.py", line 147, in connection_lost
    self.on_connection_lost.set_result(True)
asyncio.exceptions.InvalidStateError: invalid state
2024-04-25 14:52:15.767 ERROR (MainThread) [custom_components.dahua_vto.sensor] GoliathVTH: 268632085: Component error: User or password not valid!, retry in 10 seconds

You can see in the log the error Component error: User or password not valid!

For Dahua VTH user name is admin but default password can be 888888 or 002236 or 123456.
Try to login into VTH settings with any of this password and then specify it in config.
How this looks you can see here.