Dahua VTO custom integration

Tested, working great - don’t see any unexpected behavior.

Button example for HA:

type: 'custom:button-card'
icon: 'mdi:doorbell-video'
name: Doorstation - Door 1
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: auto
show_state: false

I added review approve to your commit - 2 more

2 Likes

Thanks! If you model not in supported model list, please write it here, I will add it to the list.
Looking forward for 2 more reviews :wink:

Its possible to receive event for motion detection?

If your VTO support motion detection then probably it’s possible, configure motion detection in VTO, configure integration to record all events and check. You can also turn on debugging and you will see in the log all messages from VTO not only client.notifyEventStream

If integration works for you, please help to get it approved to HACS default repo.
Approve this pull request.
On the right from Review required you should see the Add your review link, click on it and click green button at the right top Review changes select Approve and click Submit review button.
Thanks in advance!

@myhomeiot
Approved :+1:

@myhomeiot Approved :+1:

Approved :+1:

@myhomeiot Approved :+1:

Newbie question here
What’s the benefit of this over MQTT ?

I can’t say that this is benefits, but few points:

  • If you don’t have/don’t use MQTT you don’t need it (my case)
  • MQTT version run in extra docker container which you should monitor, this version run inside Home Assistant as integration and because of this it’s also has a bit faster communications

Maybe other users here have experience with both versions and will answers better.

Thanks @bar for information that you can use his MQTT or this version of integration not only with Dahua VTO/VTH but also with Dahua Cameras and NVRs.

If you will found something useful, please share it here. :wink:

Hello,
Thanks for your job.
I have a vto since 2016 and I am trying to integrate it into my home automation.
but when i put your code i got this message:
“Dahua Vto unavailable”
I put the address of my VTO, the admin user and his password.
is this due to my firmware too old?
can you help me ?
Thanks for your answer

Hello, where you get this message? Please check Home Assistant Log.
If this doesn’t help turn on debug logging and check.

i have this message in my lovelace page
this is my log …
2021-04-25 10:57:50 ERROR (MainThread) [custom_components.dahua_vto.sensor] Dahua VTO: ‘NoneType’ object has no attribute ‘get’, retry in 10 seconds
2021-04-25 10:58:00 DEBUG (MainThread) [custom_components.dahua_vto.sensor] Connecting 192.168.1.110:5000, username admin
2021-04-25 10:58:00 DEBUG (MainThread) [custom_components.dahua_vto.sensor] >>> {“method”:“global.login”,“params”:{“clientType”:"",“ipAddr”:"(null)",“loginType”:“Direct”,“userName”:“admin”,“password”:“xxx”},“id”:1,“session”:0}
2021-04-25 10:58:00 DEBUG (MainThread) [custom_components.dahua_vto.sensor] <<< { “error” : { “code” : 268632079, “message” : “Component error: login challenge!” }, “id” : 1, “params” : { “authorization” : “b7e4efa7x9a25cfxxx7ecbf82a003e99f0576a”, “encryption” : “Default”, “mac” : “4C11BF7xxx71A”, “random” : “1734403115”, “realm” : “Login to 2F03198GAN0002x” }, “result” : false, “session” : 1156731805 }
2021-04-25 10:58:00 DEBUG (MainThread) [custom_components.dahua_vto.sensor] >>> {“method”:“global.login”,“params”:{“clientType”:"",“ipAddr”:"(null)",“loginType”:“Direct”,“userName”:“admin”,“password”:“xxx”},“id”:2,“session”:1156731805}
2021-04-25 10:58:00 DEBUG (MainThread) [custom_components.dahua_vto.sensor] <<< { “id” : 2, “params” : null, “result” : true, “session” : 1156731805 }
2021-04-25 10:58:00 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorSocketTransport._call_connection_lost(None)
Traceback (most recent call last):
File “/usr/local/lib/python3.8/asyncio/events.py”, line 81, in _run
self._context.run(self._callback, *self._args)
File “/usr/local/lib/python3.8/asyncio/selector_events.py”, line 970, in _call_connection_lost
super()._call_connection_lost(exc)
File “/usr/local/lib/python3.8/asyncio/selector_events.py”, line 728, in _call_connection_lost
self._protocol.connection_lost(exc)
File “/config/custom_components/dahua_vto/sensor.py”, line 81, in connection_lost
self.on_connection_lost.set_result(True)
asyncio.exceptions.InvalidStateError: invalid state

Yes, I think it’s due your firmware too old, because it’s reply to login with empty params. What version of firmware do you have?

You VTO reply:
{"id" : 2,"params" : null, "result" : true, "session" : 1156731805}
Regular VTO reply:
{"id":2,"params":{"keepAliveInterval":60},"result":true,"session":2147483344}

You can try to see if it’s can work at all, replace this line:

            self.keepAliveInterval = params.get("keepAliveInterval")

with:

            self.keepAliveInterval = 60

If it’s helps and all rest will work as expected, let’s me know, I fix this in the integration.

i changed this line but same result :
File “/usr/local/lib/python3.8/asyncio/events.py”, line 81, in _run

self._context.run(self._callback, *self._args)

File “/usr/local/lib/python3.8/asyncio/selector_events.py”, line 970, in _call_connection_lost

super()._call_connection_lost(exc)

File “/usr/local/lib/python3.8/asyncio/selector_events.py”, line 728, in _call_connection_lost

self._protocol.connection_lost(exc)

File “/config/custom_components/dahua_vto/sensor.py”, line 81, in connection_lost

self.on_connection_lost.set_result(True)

asyncio.exceptions.InvalidStateError: invalid state

2021-04-25 14:32:16 ERROR (MainThread) [custom_components.dahua_vto.sensor] Dahua VTO: ‘NoneType’ object has no attribute ‘get’, retry in 10 seconds

2021-04-25 14:32:26 DEBUG (MainThread) [custom_components.dahua_vto.sensor] Connecting 192.16…

Do you know if it is easy to update the firmware ?

In this debug log I doesn’t see protocol messages <<< so I can’t tell you exactly why it’s doesn’t work now, if you give full debug log I can look.

Sure better to keep firmware up to date, it’s not to hard but not straight forward as well. If you have VTH as well it’s will requires more configuration. When I change firmware from 1.0 to 4.3 it’s requares reconfigure everything. First, found and write carrefully version of firmware which you have how and make backup from web interface, if something goes complettely wrong, you will be able to restore. Make screen shots of all VTO settings from web interface.

Find and download latest firmware from Dahua or partners sites, it’s can be a problem, I found firmware for my VTO in FTP: ftp://ftp.asm.cz/Dahua/videovratni
But you can try first the Dahua site
When you will need Dahua Toolbox which you can download here.
I use this video for configuration of my VTO/VTHs and this instruction for updating.

Hope this helps.

Could you send me a MP because i’m newbe and i can’t.
i send you my log

That’s ok for the VTO2000 and VTH1550 firmware 1.0 with the change self.keepAliveInterval = 60