Dahua VTO to MQTT Broker

Thanks joffrey. And is it giving you problems or is it working fine?

I had some problems at the beginning but now it’s working fine (thanks to the last updates).
I’m only using call button event.

I forked @bar repo and added/fixed 2 functions:

  • HTTPs enabled VTO device should work now (anyway it was used only to “Open” doors)
  • Added support for 2nd door lock - not tested

TOPIC: [MQTT_BROKER_TOPIC_PREFIX]/Command/Open
Payload:
- “1” - 1st Door
- “2” - 2nd Door

HA entity - Door 1:

type: 'custom:button-card'
icon: 'mdi:gate'
name: Door 1
tap_action:
  action: call-service
  service: mqtt.publish
  service_data:
    payload: 1
    topic: DahuaVTO/Command/Open

HA entity - Door 2:

type: 'custom:button-card'
icon: 'mdi:gate'
name: Door 2
tap_action:
  action: call-service
  service: mqtt.publish
  service_data:
    payload: 2
    topic: DahuaVTO/Command/Open

If someone confirms that works, then maybe @bar will update his repo so I can remove mine :slight_smile:

Thanks for the PR, I hope to get to it in the upcoming weekend

Hi @bar, there is bigger issue with your script … as it may end up in creating a lot of connection to MQTT Broker without closing previous one.

How to replicate issue:

  1. Start your script - it will connect with intercom & MQTT Broker
  2. Restart Dahua VTO - it will trigger loop where whole class “DahuaVTOClient” will be executed
  3. When intercom will go up - script will initiate connection again to intercom (no issue here) and 2nd connection to MQTT Broker without closing previous one … and subscribe to topic again - guess what will happen upon x+1 subscriptions?
  4. … and so on

We may set up “self.mqtt_client = mqtt.Client(“VTO2MQTT”)” but it won’t solve issue. It will close previous connection just fine (as only 1 client with same name can be connected to MQTT Broker), but each disconnect will create loop in “def on_mqtt_disconnect(client, userdata, rc)”

Only solution which I see is to remove all MQTT connection related tasks from “class DahuaVTOClient” and initiate it only once upon start. MQTT pahu implementation takes care just fine in restoring connection when it’s broken … so no harm done to this part.

Any other ideas?

Dahua VTO/VTH Home Assistant integration without MQTT you can find here

Any feedback will be greatly appreciated :wink:

2 Likes

Installed, working (VTO2211)
Will play more with it

Its possible to install this via HACS?

Not yet, but if you approve this pull request it’s will be possible :wink:

@myhomeiot I just installed your add-on and it works great with Dahua DHI-VTO2111D-WP. Thank you!

Thanks for update! If you found interesting events and automation which is not described in integration documentation please share them here

Hi all,

thanks for @myhomeiot for the custom component, I will keep that integration as it more useful for those who would like it to work cross-platform.

released a new version with support for multiple doors, just send in the open door topic the door ID you would like to open, by default (if not sent) it will open door 1,
payload example for another door:

{
   "Door": 2
}

In addition, i got in GitHub - DahuaVTO2MQTT - Issue #39 a request to support not just Dahua VTO with that integration but also Dahua Camera, it appears that no additional work is requeired if you would like it to work for you, instead of DAHUA_VTO_* parameters for the VTO unit, use the parameters for the camera (ip, username and password),
Events will get published just for the camera,
if you are using it, the are 2 options to diffrinciate between the devices (VTO and Camera),
By SN or by changing the MQTT Topic Prefix per docker image you are running.

thanks

Following the latest news that the docker image supports all Dahua devices, updated the opening post

Thanks a lot for the great work!

Can someone give me a hint how I can stop the ringing of the bell out of home assistant.

I can open the door out of home assistant using the Dahua API, however the bell keeps still ringing then. How domI stop it? I have tried using the hang up and refuse call calls from the Dahua API documentation, but that does not stop the ringing.

About these bells, how do you manage voice?. I mean, with all these I can receive an image from the camera through MQTT, but I don’t know how to respond to anyone that calls…

How do you have that integrated?

I don’t manage voice as I am not aware of any two way audio or SIP client integration for home assistant.

So, you only receive a message that ring a bell at home, then you see the camera and then you open the door with a nuki system or similar. Is that your automation?

Thanks.

Basically, yes, it allows you to get indication that someone is in the gate or door and then you apply any automation into it,
It also allows you to listen to other events and act upon it, and not just for Dahua VTO unit - alll Dahua NVR and Camera also supported.

Hello @bar ,
I am trying to use this addon with my Dahua NVR as it should work, but it seems it cannot connect.
Maybe because I am using HTTPS? Or a port issue?

this is what I get: the IP address of the NVR is correct … not possible to configure port or https right?


Add-on: DahuaVTO2MQTT
Listens to events from Dahua VTO unit and publishes them via MQTT Message

Add-on version: 1.0.13
You are running the latest version of this add-on.
parse error: Expected string key before ‘:’ at line 1, column 4
[17:17:28] ERROR: Unknown HTTP error occured
System: (amd64 / qemux86-64)
Home Assistant Core: 2021.5.5
Home Assistant Supervisor: 2021.04.3

[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing…
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.

2021-05-26 17:17:29,661 INFO main Connecting
2021-05-26 17:17:29,663 ERROR main Connection failed will try to connect in 30 seconds, error: [Errno 111] Connect call failed (‘180.180.180.22’, 5000), Line: 394``

can you please share the configuration? it seems that the json config is invalid

thanks