Dahua VTO to MQTT Broker

i can install it but it wont start:

[services.d] starting services
[services.d] done.
[15:24:37] INFO: Staring Dahua to MQTT
<*** Dahua VTO Event Listener START ***>
PHP Fatal error:  Uncaught Error: Call to undefined function curl_init() in /app/DahuaVTO.php:79
Stack trace:
#0 /app/DahuaVTO.php(150): DahuaVTOAPI->SetDeviceDetails()
#1 /app/DahuaVTO.php(9): DahuaVTOEventListener->DahuaVTOEventListener()
#2 {main}
  thrown in /app/DahuaVTO.php on line 79
[cmd] /bin/ash exited 255
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
-----------------------------------------------------------
                Oops! Something went wrong.

 We are so sorry, but something went terribly wrong when
 starting or running this add-on.
 
 Be sure to check the log above, line by line, for hints.
-----------------------------------------------------------
[cont-finish.d] 99-message.sh: exited 0.
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

Added the missing packages (according to article found in google),
Changed version to 1.0.7,
Please update and let me know if now it works for you,
Sorry, again, canā€™t test it here

thanks

after invetigating the issue deeper and based on my very limited expirence of PHP developement (up until this component I had RO capabilities of PHP)

At some point it disconnects and there is no indication in any library I found to understand the status,
I managed to make it work for an hour but then it stops the connection, no error while trying to send a message and the only why the do a workaround is to manage some kind of self-timeout mechanism, not going to try it, prefer to transform the code to Python (which Iā€™m already working on it).

you are 100% correct, less resources are being consumed by both client and server,
in general memory and CPU hit is not that high that itā€™s a must,
in terms of network, it consumes from client double the bandwidth of sending requests - 100 bytes in a minute over 50 bytes with 1 long-living connection,
Again, I prefer to invest the time to fix it by re-writing the code in Python.

In case someone want to join the effort, you all more than welcome :slight_smile:

thanks

this time i could not install. btw. thanks for spending time on this!

The command ā€˜/bin/ash -o pipefail -c apk add --no-cache --update argon2-libs php php-json && apk add --no-cache --virtual .build-dependencies git && apk add --update libzip-dev curl-dev && docker-php-ext-install curl && apk del gcc g++ && rm -rf /var/cache/apk/* && git clone https://github.com/elad-bar/DahuaVTO2MQTT.git --branch ${DAHUA_BRANCH} --depth 1 /app && chmod +x /app/DahuaVTO.php && apk del .build-dependenciesā€™ returned a non-zero code: 14

version 1.0.7 also does not work, error during installation!

i have exactly the same error

tried to fix it, since I donā€™t have hassio installed (using HA Core),
I no longer cannot maintain it,
If someone else would like to take it from here, please feel free to do that.

An alternative solution, which Iā€™m working with is the regular docker as in the OP / readme (in GitHub)

i know you donā€™t maintain it anymore how come it showed that new 1.0.7 who made that jump?
i really hope someone takes over

I did, as I was trying to align it to the latest docker code, I can try to revert it and hopefully it will work for you

oh ok it would be great if it worked thanks for all effords ! and enjoy your weekend

I am using this addon and I found out that it needs some improvements. for instance, when itā€™s unlocked with a card, it will publish a topic ā€˜DahuaVTO/BackKeyLight/Eventā€™ with state ā€˜8ā€™ only once, it will not publish the topic again with a different state. Itā€™s needed payload_on and payload_off when adding a binary sensor. It can also be improved by publishing the username of the card instead of the card number only.

Is it possible to unlock the door in home assistant?

Thanks for the suggestion.
Docker container created for specific use case, transform the events into MQTT messages for all kind of consumers.

Code originally written in PHP (which I personally like lessā€¦) to create listener to the Dahua unit,
since it provided the basics (transform to Python takes time) I leverged that code to publish the messages for any system would like to integrate into it.

I use NodeRED to handle the events, others HA, in general OpenHAB users can use it as well,
Hope it make sense to you

I finaly managed to run the broker (manual docker-compose). Works fine already for a week with my VTO2000A. I used the broker to launch depstack face recogition plugin and now can open the door only for recognized people :-).
Now iā€™m thinking about putting few more automations and not sure if it is possible:

  1. after i request the latch to be opened (/usr/bin/curl -s --globoff --digest --user user:password ā€˜http://x.x.x.x/cgi-bin/accessControl.cgi?action=openDoor&channel=1&UserID=101&Type=Remoteā€™ I would like to have the connection between VTO and VTH to be finished (so VTH stops ringing). Do you think it is possible?
  2. I would like to send to VTO ā€œWelcome messageā€ so the person will be invited home :slight_smile:.

Can you please advise where to look for such code?

Iā€™m doing the exact same thing but with different tools (without the component of DeepStack).
I wrote a server (over docker) that samples the cameras (18) from BlueIris server and analyze them against the DeepStack container every 1 second (didnā€™t want to wait for event and based on that to analyze the image).

The way I handle images is bit different but the rest should be the same, automation,
Iā€™m using NodeRED for that:

  • Once face identified at the desired confidence level and if the face is approved for opening the specific door / gate, it will initate http call using the same format you have wrote
  • Once a door is being opened, flow will send an announcement via Google Home about the person in which door

Node for HTTP request

[{"id":"bec90a13.7b0818","type":"http request","z":"578a93d9.200c5c","name":"Open Gate","method":"GET","ret":"txt","paytoqs":false,"url":"http://x.x.x.x/cgi-bin/accessControl.cgi?action=openDoor&channel=1&UserID=101&Type=Remote","tls":"","proxy":"","authType":"digest","x":1370,"y":120,"wires":[["602be582.94c1cc"]]}]

Node for announcement

[{"id":"e1c17286.91921","type":"api-call-service","z":"578a93d9.200c5c","name":"Google Announcement","server":"ec87011b.5f82a","version":1,"debugenabled":false,"service_domain":"tts","service":"google_translate_say","entityId":"","data":"{\t    \"entity_id\":\"media_player.x\",\t    \"message\": Flow.Message & IdentifiedNames\t}","dataType":"jsonata","mergecontext":"","output_location":"parts","output_location_type":"msg","mustacheAltTags":false,"x":1820,"y":120,"wires":[["f055fe08.41b9e"]]},{"id":"ec87011b.5f82a","type":"server","name":"Home Assistant","legacy":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

how did you manage to connect door lock to home assistant? i am new to this, so could you show the steps for the setup?

For the gate it was simple (HTTP request as described above),
the other door were bit more complicated, I have ENTR (https://www.mul-t-lock.com/en/site/mul-t-lock/for-home/entr/),
It doesnā€™t support API calls, just secured bluetooth, it provides the ability to connect fingerprint / keypad to the system,
I took one of the remote controls and rewired it into dry contact relay (from AliExpress - 4$) and now the ENTR supported by HA :slight_smile:

Iā€™ve done it before few systems released to the market, if you are looking for solution, there are lot of them in AliExpress, you just need to make sure it will work with your door

I can not get it to work with my vto2000a unfortunately.

I want to share however a nice little script that I found on the net to intercept just the button being pressed.

#!/bin/bash
while true; do sudo tcpdump -n -i eth0 -c 1 'src host vtoip and dst port 30000'; curl -k 'http://user:password@noderedip:1880/api?VTO=9'; sleep 30; done

Where You should substutitute eth0 with the eth interface of the machine where the script is running.
vtoip with you VTOā€™s IP
noderedip your nodered ip
You can substitute the post to nodered with some other way of commnicate with you automation platform

run the script in background and you are done: you will have a notif when the button is pressed

1 Like

Bar, I just dropped in to thank you for your fantastic work youā€™re doing. This is the second integration Iā€™m using from you (first being BlueIris, fantastic, rock solid, I love it), and even being new to this whole home assistant stuff it was relatively easy for me to set it up via the docker method.

I hated how the iDMSS app was sooo terribly bad from user friendliness perspective, how I always missed all doorbell rings all the time. Now I instantly get a rich notification to my iOS devices along with a custom doorbell sound, so wife approves this solution as well :slight_smile:

Iā€™d like to go on this path a little further, and I need some advice on it:

  • Iā€™d like create actionable notification, where thereā€™s a button to unlock the door. If I could get some tips on how to create a button in HA which unlocks the gate via my VTO, I would do the rest
  • Iā€™m also using Deepstack object recognition to get notifications if someone approaches my front gate, but I would love to add face recognition to automate for example door opening with recognized family members. Could someone direct me to some reading material on the topic how to teach faces to deepstack, or perhaps give me some live examples? would be much appreciated.

And again: thanks a lot for your hard work, you really make the life easier for thousands of people!

i have seen there was an update to 1.0.8 its not working sadly

DahuaVTO2MQTT
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: DahuaVTO2MQTT
 Listens to events from Dahua VTO unit and publishes them via MQTT Message
-----------------------------------------------------------
 Add-on version: 1.0.8
 There is an update available for this add-on!
 Latest add-on version: null
 Please consider upgrading as soon as possible.
parse error: Expected string key before ':' at line 1, column 4
[19:28:56] ERROR: Unknown HTTP error occured
 System:   (armv7 / raspberrypi3)
 Home Assistant Core: 0.117.1
 Home Assistant Supervisor: 2020.10.0
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[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.
[19:29:01] INFO: Staring Dahua to MQTT
2020-11-01 18:29:01	<*** Dahua VTO Event Listener START ***>
PHP Fatal error:  Uncaught Error: Call to undefined function curl_init() in /app/DahuaVTO.php:106
Stack trace:
#0 /app/DahuaVTO.php(91): DahuaVTOAPI->SetDeviceDetails()
#1 /app/DahuaVTO.php(179): DahuaVTOAPI->DahuaVTOAPI()
#2 /app/DahuaVTO.php(9): DahuaVTOEventListener->DahuaVTOEventListener()
#3 {main}
  thrown in /app/DahuaVTO.php on line 106
[cmd] /bin/ash exited 255
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
-----------------------------------------------------------
                Oops! Something went wrong.

 We are so sorry, but something went terribly wrong when
 starting or running this add-on.
 
 Be sure to check the log above, line by line, for hints.
-----------------------------------------------------------
[cont-finish.d] 99-message.sh: exited 0.
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

I am using facebox and works pretty well for recognition