Dahua IPC to MQTT App

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

I spent the good part of 2 days trying to install Pycurl using HASSIO. I tried every combination until finally this is what worked:

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

I suspect as pip gets updated you may need to change the 19.3.1 but right now this is working.

Since a few days I got this error:

INFO DahuaMQTT: [192.168.1.40] OnDisconnect(Empty reply from server (52))

Any thoughts?

Can you show how you done in config yaml homeassistant has come so far but does not get mqtt the sensor to work I get this error message suspects that I got hold of an old code that no longer works

the code i use

  • platform: mqtt
    name: “motion_cam01”
    state_topic: “cameras/2”
    payload_on: “start”
    payload_off: “stopp”
    value_template: ‘{{ value_json.action }}’
    device_class: motion

and the error mess

2019-12-27 13:48:33 ERROR (MainThread) [homeassistant.components.homeassistant] Invalid config for [sensor.mqtt]: [payload_on] is an invalid option for [sensor.mqtt]. Check: sensor.mqtt->payload_on. (See ?, line ?). Please check the docs at https://home-assistant.io/integrations/mqtt/

you are trying to add an mqtt sensor:

looking in the docs show that there is no option payload_on or payload_off, which is also stated by the error.

Yes I know there must have been some change in it since as I understood it has worked before and have read that instruction but am too green on this to understand exactly what to replace those commands with

HA has become more particular about lines in the config file that it doesn’t understand. Previously, it would have ignored them, now it throws an error.

For a mqtt sensor, the sensor takes on whatever value the message payload contains (modified by the payload template), so ‘payload_on’ and ‘payload_off’ are meaningless. You can just remove them.

have you this working still

got errors

got ths now

2019-12-27 17:37:00 ERROR (MainThread) [homeassistant.components.homeassistant] Invalid config for [sensor.mqtt]: value is not allowed for dictionary value @ data[‘device_class’]. Got ‘motion’. (See ?, line ?). Please check the docs at https://home-assistant.io/integrations/mqtt/

motion sensors wont work with start stopp.
so if you delete the device_class it will work

Hi,

This what I have and it is working. I’ve installed AppDaemon and Mosquitto Broker.

In /config/appdaemon/apps/apps.yaml

Blockquote
dahua_mqtt:
module: dahua_mqtt
class: DahuaMQTT

DahuaMQTT:
class: DahuaMQTT
module: dahua_mqtt
cameras:
- host: ipaddresshere
port: 80
user: userhere
pass: passwordhere
topic: cameras/1
events: VideoMotion,AlarmLocal,CrossLineDetection,CrossRegionDetection,LeftDetection,TakenAwayDetection,VideoAbnormalDetection

Then in configuration.yaml

binary_sensor:

  • platform: mqtt
    name: motion_cam01
    state_topic: cameras/1
    payload_on: Start
    payload_off: Stop
    value_template: ‘{{ value_json.action }}’
    device_class: motion

Then I’ve created an automation rule in automations.yaml which will record a video to a specific folder once movement has been detected.

  • alias: dahua_motion_record
    trigger:
    • entity_id: binary_sensor.motion_cam01
      from: ‘off’
      platform: state
      to: ‘on’
      condition:
      action:
      • service: camera.record
        data_template:
        entity_id: camera.dahua_frontdoor_low
        filename: “/config/www/ipcam/Frontdoor {{ now ().day }}.{{ now ().month}} {{ now ().hour }}:{{ now ().minute }}:{{ now ().second }}.mp4”
        duration: 10

Hope this helps.

After upgrading to the latest version of HassIO 3.7, AppDaemon stopped working. Below the setup I got it up working again. I marked in bold the additions to my previous setup.

{
“disable_auto_token”: false,
“system_packages”: [
“musl”,
“libcurl”,
“python3”,
“python3-dev”,
“libcrypto1.1”,
“libssl1.1”,
“curl-dev”,
“gcc”,
“g++”
],
“python_packages”: [
“hass-apps”,
“pip==19.3.1”,
“pycurl”
],
“log_level”: “info”
}

1 Like