Dahua VTO to MQTT Broker

Maybe we can figure out why it isn’t working for us, but it is for you. I think it would be better not to reconnect the whole time, but keep the connection open as you did in your last version.

I’m running eclipse-mosquitto in Docker, (latest) version 1.6.12. Which mosquitto-server are you guys running?

Hello! there is such a problem, I don’t know how to solve it, the addon does not want to be installed (
Synology system, Docker, Home Assistent

As for me, the recent version is not correct operation.
The 1st problem is disconnecting from mqtt broker in ~10 sec (defaut timeout).

1602927189: New client connected from 10.100.101.62 as dahua-vto-dahuavto (p1, c1, k10, u'my_mqtt_user').
1602927204: Client dahua-vto-dahuavto has exceeded timeout, disconnecting.

To fix that problem I added missed row after the new phpMQTT object creation at file DahuaEventHandler.php:

$mqtt->keepalive = $this->keepAliveInterval;

It’s OK now, but the 2nd problem remains. If you suddenly stop your broker, try block for $mqtt->publish doesn’t catch the exeption and you can see “MQTT message published” when the connection to broker already gone. It’s need to fix that moment.

2 Likes

Great! I’m having the same issue, but I’m total noob with containers at this point, so have to wait for update.

Again, thanks @meteonet. I installed nano within my portainer container, added that row to DahuaVTO.php and got it working instead of timeouts. Now I can continue with my project while waiting for rest of the fixes!

Now, when installing the add-on, it gives the following error

Released new version with fix for the MQTT disconnections, reverted to per message connection

1 Like

same error when installing the addons

Thanks for the quick fix. However, I think it would be better to release a new version with the fix from meteonet. What’s the reason you reverted to the old way of connecting. Wouldn’t it be better to keep the connection open using the keep-alive interval?

Same here - looks there is missing file in repo (DahuaEventHandler) or other issue stopping the installation:
Failed to install addon
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 && git clone https://github.com/elad-bar/DahuaVTO2MQTT.git --branch ${DAHUA_BRANCH} --depth 1 /app && mv /app/DahuaEventHandler.php /app/DahuaVTO.php && chmod +x /app/DahuaVTO.php && apk del .build-dependencies’ returned a non-zero code: 1

Me too. cant install - i was enjoying the wooden door knock sound on my volumio :slight_smile:

Fixed it and updated the version of the addon to 1.0.6,
should work now, can’t test it because I’m using HA core

I will check @meteonet’s solution and if it works, I will release an additional version

thanks

I’m sorry - I stucker here …

Still getting the message in the log:

parse error: Expected string key before ‘:’ at line 1, column 4
[00:10:15] ERROR: Unknown HTTP error occured

Honstly I do not know where should I find the line 1 and column 4.

Currently working on separate system (docker) and manual run (php). I hope I find the reason why this script fails here :frowning:

One more request for @bar
I’m using Dahua VTO 2000A and most of code runs well in docker with manual run (php).
There is however one issue:

MQTT message published Topic: DahuaVTO/VideoMotion/Event Payload: {“Action”:“Start”,“Data”:{“LocaleTime”:“2020-10-23 19:46:45”,“UTC”:1603475205},“deviceType”:“VTO2000A-2”,“serialNumber”:“xxxxxxx”}
Event Call from VTO
MQTT message published Topic: DahuaVTO/CallNoAnswered/Event Payload: {“Action”:“Start”,“Data”:{“CallID”:“3”,“IsEncryptedStream”:false,“LocaleTime”:“2020-10-23 19:46:46”,“LockNum”:2,“SupportPaas”:false,“TCPPort”:37777,“UTC”:1603475206},“deviceType”:“VTO2000A-2”,“serialNumber”:“xxxxxxx”}
PHP Notice: Undefined variable: eventList in /home/xxxxxxx/DahuaVTO2MQTT/DahuaEventHandler.php on line 454
PHP Notice: Trying to access array offset on value of type null in /home/xxxxxxx/DahuaVTO2MQTT/DahuaEventHandler.php on line 454

I think it is small issue as it looks as error in logging.

not sure I understand it, are you running it in the original docker or manual?

DahuaEventHandler.php was renamed in latest version, and line 454 is not available in that version for new modified file.

,

Oups - I messed up yesterday.
I’m currently running 2 environments:
1: the one which is woking is regular linux machine with older code. it is started manualy as it was only version I could make it working here.
2: raspburry pi 4 with HA installed - this one I would like to run, but cant install from repository ( parse error: Expected string key before ‘:’ at line 1, column 4 [00:10:15] ERROR: Unknown HTTP error occured)

Anyway - at least we know that VTO2000 works well.

Is the 2nd env. using the docker or addon?
As for the env. you are running manual, try to take latest code and use it.

Docker on rasp pi.

Hello! the same error. Doesn’t want to install 1.0.6

20-10-24 10:42:23 ERROR (SyncWorker_6) [supervisor.docker.addon] Can't build 26703e67/amd64-addon-dahuavto2mqtt:1.0.6: 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 &&     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: 129```