Dahua VTO to MQTT Broker

ok, i just re installed it and will see how it goes

hy Bar,
thanks for the work and great integration. I use it for my Dahua Cam and would like to use the IVS-rules as sensor in HA. would you happen to know how i can use it as sensor? (command-line for binary sensor?)



the second sensor get’s the stop command but not the start command.

thanks

Hi guys, I’m attempting to setup the dahuavto2mqtt service with mosquitto and home assistant using docker-compse on a ubuntu machine. I’ve already got various shelly devices connected to the mosquitto MQTT broker and home-assistant and I can pub and sub to mosquitto with the following from my windows machine succesfully:
sub: mosquitto_sub.exe -h <mosquitto-ip> -u <myusername> -P <mypassword> -t DahuaVTO/# -F %j
pub mosquitto_pub.exe -h <mosquitto-ip> -u <myusername> -P <mypassword> -t DahuaVTO/test -m "{'message': 'test1'}"

When attaching to the running dahuavto2mqtt container I can see the following debug output repeating:

2022-05-30 18:19:22,502 INFO __main__ Connecting
2022-05-30 18:19:22,502 DEBUG asyncio Using selector: EpollSelector
2022-05-30 18:19:22,504 DEBUG __main__ Connection established
2022-05-30 18:19:22,504 INFO __main__ Initializing MQTT Broker
2022-05-30 18:19:22,505 INFO __main__ MQTT Broker is trying to connect...
2022-05-30 18:19:22,506 DEBUG __main__ Prepare pre-login message
2022-05-30 18:19:22,506 INFO __main__ MQTT Broker connected with result code 0
2022-05-30 18:19:22,519 DEBUG __main__ Data received: {'error': {'code': 268632079, 'message': 'Component error: login challenge!'}, 'id': 2, 'params': {'authorization': '36f94ca7<..etc..>f56f8d49f', 'encryption': 'Default', 'mac': '<mac address>', 'random': '1853980012', 'realm': 'Login to f9b3bdac<..etc..>c6731dec049'}, 'result': False, 'session': 2147483588}
2022-05-30 18:19:22,519 DEBUG __main__ Prepare login message
2022-05-30 18:19:22,538 DEBUG __main__ Data received: {'error': {'code': 268632085, 'message': 'Component error: User or password not valid!'}, 'id': 3, 'params': {'remainLockSecond': 0, 'remainLoginTimes': 0}, 'result': False, 'session': 2147483588}
2022-05-30 18:19:22,748 INFO __main__ Server sent EOF message
2022-05-30 18:19:22,748 WARNING __main__ Disconnected, will try to connect in 5 seconds

The relevant parts from docker-compose.yml:

version: '3.7'

services:
   homeassistant:
      container_name: homeassistant
      image: homeassistant/home-assistant:stable
      volumes:
         - /home/myusername/HA/config:/config
         - /etc/localtime:/etc/localtime:ro
      restart: unless-stopped
      network_mode: host

   mosquitto:
      image: eclipse-mosquitto:latest
      depends_on:
         - homeassistant
      ports:
         - 1883:1883
         - 9001:9001
      volumes:
         - /home/myusername/HA/mosquitto/config:/mosquitto/config
         - mosquitto_data:/mosquitto/data
         - mosquitto_logs:/mosquitto/logs
      restart: unless-stopped
      network_mode: host

   dahuavto2mqtt:
      image: "eladbar/dahuavto2mqtt:latest"
      container_name: "dahuavto2mqtt"
      network_mode: host
      depends_on:
         - mosquitto
      restart: unless-stopped
      # relies on .env file
      environment:
         - DAHUA_VTO_HOST=${DAHUA_VTO_HOST}
         - DAHUA_VTO_USERNAME=${DAHUA_VTO_USERNAME}
         - DAHUA_VTO_PASSWORD=${DAHUA_VTO_PASSWORD}
         - MQTT_BROKER_HOST=${MQTT_BROKER_HOST}
         - MQTT_BROKER_PORT=${MQTT_BROKER_PORT}
         - MQTT_BROKER_USERNAME=${MQTT_BROKER_USERNAME}
         - MQTT_BROKER_PASSWORD=${MQTT_BROKER_PASSWORD}
         - MQTT_BROKER_TOPIC_PREFIX=DahuaVTO
         - MQTT_BROKER_CLIENT_ID=DahuaVTO2MQTT
         - DEBUG=true

volumes:
   mosquitto_data: {}
   mosquitto_logs: {}

when I run docker-compose config I can see that the env-vars from the .env file are filled in succesfully. Any idea to what this could cause? I have the feeling I’m missing something obvious here (besides that the broker somehow thinks the credentials are wrong) :sweat_smile:

hi, I moved the repo to GitLab and forgot to update the original post, now it’s updated.

Image is available at:
registry.gitlab.com/elad.bar/dahuavto2mqtt:latest

ever since I moved it to GitLab I applied several additional fixes, pls check with the up to date image if the problem is gone, if not, pls let me know.

thanks

1 Like

Hi Bar, thanks for your swift response, I’ll check it as soon as I get home this evening!

update: @bar thank you very much, that fixed it for me! now I can start the automation fun :grin: :partying_face:

switch:  
  - platform: command_line
    switches:
      dahua_gate_open:
        command_on: "/usr/bin/curl -s --globoff --digest --user YOUR_WEB_ADMIN_USERNAME:YOURPASSWORD 'http://XXX.XXX.X.XXX/cgi-bin/accessControl.cgi?action=openDoor&channel=1&UserID=101&Type=Remote'"
        friendly_name: 'Open yard door'

@Guesswho620 - Thanks - tonight was one of those great times where you google for the easiest method to trigger something, the first link sends me to the right place (your post). Much appreciated, worked first pop

1 Like

Thanks for the kind words, after so many similar events happened to me, it’s fantastic that I could make the same happen to someone :slight_smile:

I love this place

1 Like

Hi guys. I’m approaching to buy vto3211 4btn and integrate it in HA.
But it’s not clear to me if I can obtain what’s the button pressed by the user.
Some posts above I read something about that, but not a reply…
Is that possible?

Hey, I listen to the doorbell using the broker from this topic and the following binary sensor:

- name: "Doorbell Button State"
  unique_id: "Doorbell_Button_State"
  payload_off: "0"
  payload_on: "1"
  state_topic: "DahuaVTO/BackKeyLight/Event"
  value_template: '{{ value_json.Data.State }}'

and use it in my automation as a trigger like:

  trigger:
    - platform: state
      entity_id: binary_sensor.doorbell_button_state
      from: 'off'
      to: 'on'

Guys, what’s the situation with this project because I’m a little bit lost and it doesn’t work anymore.
The events are still being published, I have a reference for a binary sensor but that sensor is not existing anymore and I cannot find/remember how it was created before.

I have installed v1.0.2 (DahuaVTO2MQTT from Troy Kelly’s Add Ons), ‘Support’ refers to a GH page that doesn’t exist anymore.
From the ‘About’ section:

Using elad-bar’s PHP code this addon simply connects to your intercom and relays events via your MQTT gateway.

Thanks for any help!

In OP you have link to docker image as standalone container (not HA Addon) that is up to date and working,
Addon is not maintained

1 Like

Trying to install DahuaVTO2MQTT addon but receive an error message

The command ‘/bin/ash -o pipefail -c apk update && apk upgrade && apk add --no-cache python3 py3-pip py3-setuptools git && pip3 install --upgrade pip --no-cache-dir paho-mqtt requests’ returned a non-zero code: 3

anyone able to decrypt and help…thanks!

Are you running it on raspberry pi?

Thanks

I am Bar…thanks for your reply :slight_smile:

Currently it is not supported, will try to get to it next weekend and add support for raspberry pi

2 Likes

Thanks!! I need you jelp too :sweat_smile:

I’ve been out and replaced my Raspberry Pi with an NUC, installed evereything from the back up I created off the Pi, tried to install VTO to MQTT Broker only to receive the error message;

The command ‘/bin/ash -o pipefail -c apk update && apk upgrade && apk add --no-cache python3 py3-pip py3-setuptools git && pip3 install --upgrade pip --no-cache-dir paho-mqtt requests’ returned a non-zero code: 3

Is there something nasty left over from Raspberry Pi install that is stopping the install or is the Dahua VTO add on not liking my NUC??

Many thanks…!

I will check it, just to make sure, source of the docker is gitlab registry, right?

Yes Bar, trying to install from the HACS Addon Store

Can you pls share the link?
I’m not supporting any HACS integration nor addon,
Just plain docker image that you can run on non raspberry pi devices