Dahua IPC to MQTT App

Hi,
I haven’t found a solution and I don’t know what to try next.

Hi, you should to install MQTT and create user, after that all working.

  1. Install the Mosquitto add-on with the default configuration via ‘Hass.io > ADD-ON STORE’. (Don’t forget to start the add-on & verify that ‘Start on boot’ is enabled.)
  2. Create a new user for MQTT via the Configuration > Users (manage users) . (Note: This name cannot be “homeassistant” or “addon”)
  3. Once back on-line, return to Configuration > Integrations and select configure next to MQTT .
Broker: YOUR_HASSIO_IP_ADDRESS
Port: 1883
Username: MQTT_USERNAME
Password: MQTT_PASSWORD

I don’t like one more thing…APPDaemon reinstall all this packages
{
“disable_auto_token”: false,
“system_packages”: [
“libcurl”,
“python3-dev”,
“curl-dev”,
“gcc”,
“g++”
],
“python_packages”: [
“pip==19.0.2”,
“pycurl”
]
}
every restart. What I can do with this?

that cant be helped, that is how the addons in hassio work.

Thank you, Rene.

Could you please help me with my configuration?

binary_sensor:

  • platform: mqtt
    state_topic: “home-assistant/cameras/1VideoMotion”
    name: “garden_camera”

  • platform: mqtt
    state_topic: “home-assistant/cameras/2VideoMotion”
    name: “gates_camera”

  • platform: mqtt
    state_topic: “home-assistant/cameras/3VideoMotion”
    name: “door_camera”

  • alias: binary_sensor_door_camera
    initial_state: True
    trigger:
    platform: state
    entity_id: binary_sensor.door_camera
    to: ‘on’
    condition:

    • condition: state
      entity_id: alarm_control_panel.home_alarm
      state: armed_home
      action:
      service: notify.telegram
      data:
      title: ‘Send a message
      message: “Motion in front of the door !”

“VideoMotion”, “action”: “Stop”, “index”: “0”}
2019-08-29 16:45:14.749690 INFO DahuaMQTT: [192.168.16.45] Publishing MQTT. topic=cameras/2VideoMotion, payload=Stop
2019-08-29 16:45:14.804947 INFO DahuaMQTT: [192.168.16.31] Publishing MQTT. topic=cameras/1, payload={“code”: “VideoMotion”, “action”: “Stop”, “index”: “0”}
2019-08-29 16:45:14.848530 INFO DahuaMQTT: [192.168.16.31] Publishing MQTT. topic=cameras/1VideoMotion, payload=Stop
2019-08-29 16:45:14.891154 INFO DahuaMQTT: [192.168.16.45] Publishing MQTT. topic=cameras/2, payload={“code”: “VideoMotion”, “action”: “Stop”, “index”: “0”}
2019-08-29 16:45:14.935085 INFO DahuaMQTT: [192.168.16.45] Publishing MQTT. topic=cameras/2VideoMotion, payload=Stop
2019-08-29 16:45:14.986980 INFO DahuaMQTT: [192.168.16.45] Publishing MQTT. topic=cameras/2, payload={“code”: “VideoMotion”, “action”: “Stop”, “index”: “0”}
2019-08-29 16:45:15.032796 INFO DahuaMQTT: [192.168.16.45] Publishing MQTT. topic=cameras/2VideoMotion, payload=Stop
2019-08-29 16:45:15.075953 INFO DahuaMQTT: [192.168.16.45] Publishing MQTT. topic=cameras/2, payload={“code”: “VideoMotion”, “action”: “Stop”, “index”: “0”}
2019-08-29 16:45:15.126626 INFO DahuaMQTT: [192.168.16.45] Publishing MQTT. topic=cameras/2VideoMotion, payload=Stop

But I don’t get messages to Telegram…

first i must say, please use codeblocks to show yaml or logs ( 3x ` on an empty line before and after the code)

second, you will only get message to telegram if you have automations that send messages.

I finally got this working with instructions from these post. Thank you all for posts and support. So I have now AppDaemon and Mosquitto MQTT addon installed. I’ve then created the binary sensor and an automation to trigger the recording once the movement is detected.

I then installed “Gallery panel for images and videos” to access and to visualize the videos Dahua has recorder.

Last problem I’m facing is the delay from the actual movement and the recording starts. There is about 3 second on ”missing”. I don’t know where this delay is coming: MQTT receives the message, automation tigger or video recording starts.

What kind of delays are you having and any ideas on how to make it shorter?

I refer to a problem earlier in this thread.
I am having the same package missing problem.
I placed the requiremetnts.txt file wherever I could but it does not get read at startup by AD

Is there some “switch” or flag to force?

How can I installpycurl and pyad (missing)

2019-09-15 01:09:21.184125 WARNING AppDaemon: ------------------------------------------------------------
2019-09-15 01:11:19.960312 WARNING AppDaemon: ------------------------------------------------------------
2019-09-15 01:11:19.960376 WARNING AppDaemon: Unexpected error loading module: /home/reinan/.appdaemon/conf/apps/dahua_mqtt.py:
2019-09-15 01:11:19.960415 WARNING AppDaemon: ------------------------------------------------------------
2019-09-15 01:11:19.960881 WARNING AppDaemon: Traceback (most recent call last):
  File "/home/reinan/appdaemon/lib/python3.7/site-packages/appdaemon/appdaemon.py", line 2026, in check_app_updates
    self.read_app(mod["name"], mod["reload"])
  File "/home/reinan/appdaemon/lib/python3.7/site-packages/appdaemon/appdaemon.py", line 1809, in read_app
    self.modules[module_name] = importlib.import_module(module_name)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/reinan/.appdaemon/conf/apps/dahua_mqtt.py", line 3, in <module>
    import pycurl
ModuleNotFoundError: No module named 'pycurl'

2019-09-15 01:11:19.960937 WARNING AppDaemon: ------------------------------------------------------------
2019-09-15 01:11:19.964098 WARNING AppDaemon: ------------------------------------------------------------
2019-09-15 01:11:19.964155 WARNING AppDaemon: Unexpected error loading module: /home/reinan/.appdaemon/conf/apps/home_presence_app.py:
2019-09-15 01:11:19.964193 WARNING AppDaemon: ------------------------------------------------------------
2019-09-15 01:11:19.964379 WARNING AppDaemon: Traceback (most recent call last):
  File "/home/reinan/appdaemon/lib/python3.7/site-packages/appdaemon/appdaemon.py", line 2026, in check_app_updates
    self.read_app(mod["name"], mod["reload"])
  File "/home/reinan/appdaemon/lib/python3.7/site-packages/appdaemon/appdaemon.py", line 1809, in read_app
    self.modules[module_name] = importlib.import_module(module_name)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/reinan/.appdaemon/conf/apps/home_presence_app.py", line 1, in <module>
    import adbase as ad
ModuleNotFoundError: No module named 'adbase'

2019-09-15 01:11:19.964427 WARNING AppDaemon: ------------------------------------------------------------

Hi,
I’ve been using this appdaemon without issue for a few months.
So I have or had a working setup.

Today, I can not run appdaemon with the previously discussed package configuration.

{
  "disable_auto_token": false,
  "system_packages": [
    "libcurl",
    "python3-dev",
    "curl-dev",
    "gcc"
  ],
  "python_packages": [
    "pip==19.0.2",
    "pycurl"
  ]
}

The error I get with this configuration is:

[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... 

-----------------------------------------------------------
 Hass.io Add-on: AppDaemon
 Python Apps and HADashboard using AppDaemon 3.x for Home Assistant
-----------------------------------------------------------
 Add-on version: 4.0.3
 You are running the latest version of this add-on.
 System: Fedora 30 (Server Edition)  (amd64 / qemux86-64)
 Home Assistant version: 0.98.5
 Supervisor version: 188
-----------------------------------------------------------
 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] appdaemon.sh: executing... 
[13:02:06] INFO: Updating Hass.io API token in AppDaemon with the current one...
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
v3.10.2-55-g6cecf3cc9d [http://dl-cdn.alpinelinux.org/alpine/v3.10/main]
v3.10.2-42-g95d37f7648 [http://dl-cdn.alpinelinux.org/alpine/v3.10/community]
v20190809-2816-gc29a90ed35 [http://dl-cdn.alpinelinux.org/alpine/edge/main]
v20190809-2814-g70fcce09f3 [http://dl-cdn.alpinelinux.org/alpine/edge/community]
v20190809-2817-g1d8c4a88bb [http://dl-cdn.alpinelinux.org/alpine/edge/testing]
OK: 25321 distinct packages available
OK: 76 MiB in 33 packages
(1/2) Installing pkgconf (1.6.1-r1)
(2/2) Installing python3-dev (3.7.3-r0)
Executing busybox-1.30.1-r2.trigger
OK: 117 MiB in 35 packages
ERROR: unsatisfiable constraints:
  libcrypto1.1-1.1.1c-r0:
    breaks: openssl-dev-1.1.1d-r0[libcrypto1.1=1.1.1d-r0]
    satisfies: world[libcrypto1.1=1.1.1c-r0]
               ca-certificates-20190108-r0[so:libcrypto.so.1.1]
               python3-3.7.3-r0[so:libcrypto.so.1.1]
               libcurl-7.66.0-r0[so:libcrypto.so.1.1]
               apk-tools-2.10.4-r2[so:libcrypto.so.1.1]
               libssl1.1-1.1.1c-r0[so:libcrypto.so.1.1]
               libtls-standalone-2.9.1-r0[so:libcrypto.so.1.1]
  libssl1.1-1.1.1c-r0:
    breaks: openssl-dev-1.1.1d-r0[libssl1.1=1.1.1d-r0]
    satisfies: world[libssl1.1=1.1.1c-r0]
               python3-3.7.3-r0[so:libssl.so.1.1]
               libcurl-7.66.0-r0[so:libssl.so.1.1]
               apk-tools-2.10.4-r2[so:libssl.so.1.1]
               libtls-standalone-2.9.1-r0[so:libssl.so.1.1]
[13:02:13] FATAL: Failed installing package curl-dev
[cont-init.d] appdaemon.sh: exited 1.
[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] appdaemon.sh: executing... 
[cont-finish.d] appdaemon.sh: exited 0.
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

package curl (not curl-dev) does install, but fails with missing binaries curl-config IIRC.

Any ideas? is it just me?

@dvbit, you need the config I’m referring in my post. Hopefully it works for you - let me know?
btw it goes in hass.io -> AppDaeomon -> and paste it in the Config section of webinterface.

Same here. Reported https://github.com/hassio-addons/addon-appdaemon3/issues/50

Exactly the same output on the error.

I amon home assistant not hassio but will try to put it … everywhere.
I tried already unfortunately.
@ReneTode any clue? Thanks all

the problem is that packages are reinstalled every time you start appdaemon.
it has 1 upside, and that is that you always use the latest version from the packages.
and thats also the downside.
as soon as something changes in 1 of the packages, and it breaks you are screwed.

in this case curl dev is updated and has other expectations.
so all you can do is find out what curl-dev needs and make sure that is installed.

or open an issue for curl-dev and tell them it cant be installed on alpine-linux

There is a workaroud until Appdaemon image is updated.

Remove curl-dev systempackage and pycurl from your config .Start Appdaemon and enter the container by typing

docker run -it <image name> bash

You get the docker image name by typing

docker ps -a

In the docker container, type following.

apk del libcrypto1.1
apk del libssl1.1
apk add curl-dev
pip3 install pycurl

After that you will get the app working. If you don’t want that, just wait for an update of Appdaemon.

Appdaemon3 4.1.0 solved the issue!:+1:t2::hugs:

rmf79,
did you re-work the configuration?

i’ve upgraded to app daemon 4.1.0, but kept the configuration as before.

which looks like this:

Installing collected packages: pycurl
  Running setup.py install for pycurl: started
    Running setup.py install for pycurl: finished with status 'error'
    Complete output from command /usr/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-xoo2i69n/pycurl/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-xlfo4kmg/install-record.txt --single-version-externally-managed --compile:
    Using curl-config (libcurl 7.66.0)
    Using SSL library: OpenSSL/LibreSSL/BoringSSL
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/curl
    copying python/curl/__init__.py -> build/lib.linux-x86_64-3.7/curl
    running build_ext
    building 'pycurl' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/src
    gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -DTHREAD_STACK_SIZE=0x100000 -fPIC -DPYCURL_VERSION="7.43.0.3" -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/docstrings.c -o build/temp.linux-x86_64-3.7/src/docstrings.o
    In file included from src/pycurl.h:4,
                     from src/docstrings.c:4:
    /usr/include/python3.7m/Python.h:11:10: fatal error: limits.h: No such file or directory
     #include <limits.h>
              ^~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-xoo2i69n/pycurl/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-xlfo4kmg/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-xoo2i69n/pycurl/
You are using pip version 19.0.2, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[19:31:29] FATAL: Failed installing package pycurl
[cont-init.d] appdaemon.sh: exited 1.
[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] appdaemon.sh: executing... 
[cont-finish.d] appdaemon.sh: exited 0.
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

Hi umbramalison,

I’m using this setup in the appdaemon hass.io add-on.


{
  "disable_auto_token": false,
  "system_packages": [
    "libc-dev",
    "libcurl",
    "python3-dev",
    "curl-dev",
    "gcc",
    "g++"
  ],
  "python_packages": [
    "pip==19.2.3",
    "pycurl"
  ],
  "log_level": "info"
}

thanks rmf79.

i was hoping to reply with great that works and btw I found i didn’t need libc-dev… this was working yesterday!

but i then thought i’d double check, restarted appdaemon and now it doesn’t work again!

now the error is:

ERROR: unsatisfiable constraints:
  python3-3.7.3-r0:
    breaks: python3-dev-3.7.4-r0[python3=3.7.4-r0]
    satisfies: world[python3=3.7.3-r0]
[22:24:43] FATAL: Failed installing package python3-dev
[cont-init.d] appdaemon.sh: exited 1.
[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.
-----------------------------------------------------------

i think i might look for another way to run these apps, if there is anything more robust than appdaemon plugin.

beginning to understand the errors.

here is a working config for me:

{
  "disable_auto_token": false,
  "system_packages": [
    "libcurl",
    "python3",
    "python3-dev",
    "curl-dev",
    "gcc",
    "g++"
  ],
  "python_packages": [
    "hass-apps",
    "pip==19.2.3",
    "pycurl"
  ]
}
1 Like

Hi

Sounds intersting, but also complicated for non-programmers :slight_smile:

How reliable and fast it is ?
At the moment I’m using motioneye, also as camera motion sensor but delay is signifcant, 5-8 seconds…
Guess Dahua directly can do it faster.

Thanks!

Strange thing. I’ve managed to start my appdaemon using this config:

  "disable_auto_token": false,
  "system_packages": [
    "libcurl",
    "python3",
    "python3-dev",
    "curl-dev",
    "gcc",
    "g++"
  ],
  "python_packages": [
    "hass-apps",
    "pip==19.3.1",
    "pycurl==7.43.0.3"
  ]
}

Yes, I’m using hass-apps, as well.
Now I’m getting the following error while trying to validate my configuration.yaml

Component error: dahua_event - Requirements for dahua_event not found: ['pycurl>=7'].

I’m on hassio 0.100.3