Dahua VTO custom integration

@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

Excellent! I will fix keep alive for firmware 1.0 in the next version, so you can make regular update when it’s will be available.

2 Likes

I’m planning to buy a VTO and great to see this custom integration.
As I understand, this integration may help to detect when the doorbell is pushed or ring then it is the good trigger for the automation in Home Assistant.

By the way, is able to stream the video from VTO to HA?

I’m thinking about the automation that when someone push the button on the doorbell, the video from doorbell will be streamed to a cast device such as smart TV automatically.

Thank you.

Yes, it’s will allow you to receive events from VTO/VTH (some Dahua Cameras and NVR’s will also works) and allow to send any commands like open the lock, etc (some useful links with commands you can found at the end of README).

You can integrate video from VTO using Home Assistant generic camera, example:

    name: Doorbell
    still_image_url: https://192.168.1.110/cgi-bin/snapshot.cgi?channel=1
    stream_source: rtsp:/192.168.1.110:554/cam/realmonitor?channel=1&subtype=0
    username: !secret vto_username
    password: !secret vto_password
    authentication: digest
    verify_ssl: false

If you use Apple Homekit you can specify for this camera the doorbeel and video will automatically popup with a message:

  - name: HA Camera Doorbell
    port: 55771
    mode: accessory
    filter:
      include_entities:
        - camera.doorbell
    entity_config:
      camera.doorbell:
        name: Doorbell
        linked_doorbell_sensor: binary_sensor.doorbell

How to integrate bi-directional audio I doesn’t know yet.

2 Likes

Thank you for your quick response. I’m very appreciated on sharing the great integration.

Approved! :slight_smile:

1 Like

what i have to do to have a vto and a nvr both dahua ?
i need to install the Integration again with Dahua NVR name insted of Dahua VTO name folder ?