Domoticz plugins support?

domoticz

#1

Hello,

i’ve setup domoticz and wanted to add the plugin to manage my Xiaomi Air Purifier 2S.
I logged in to the container and started working on the shell, installing the plugin file in the /config path.

In the installation instruction, a python module is required (python-miio), but pip3 failed to install it:

root@21945863c5c1:/config/plugins$ pip3 install -U python-miio
The directory '/config/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/config/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting python-miio
  Downloading https://files.pythonhosted.org/packages/22/2b/2496f53ea46ee5a30424b900e77ce6de4892ec5e2b8cf7300a1c20e5e0b2/python_miio-0.4.4-py3-none-any.whl (117kB)
    100% |████████████████████████████████| 122kB 5.4MB/s 
Collecting pretty-cron (from python-miio)
  Downloading https://files.pythonhosted.org/packages/18/52/d981fdd2ff0dbe660cfad6a571c596adf65eb7b25d789bd5547ce5dfdf44/pretty_cron-1.2.0-py2.py3-none-any.whl
Collecting tqdm (from python-miio)
  Downloading https://files.pythonhosted.org/packages/ed/d6/3458d39cf4978f4ece846295e83daf5ece710ab0a4106774f7f7b3a68697/tqdm-4.29.1-py2.py3-none-any.whl (46kB)
    100% |████████████████████████████████| 51kB 12.0MB/s 
Collecting click (from python-miio)
  Downloading https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl (81kB)
    100% |████████████████████████████████| 81kB 11.7MB/s 
Collecting cryptography (from python-miio)
  Downloading https://files.pythonhosted.org/packages/f3/39/d3904df7c56f8654691c4ae1bdb270c1c9220d6da79bd3b1fbad91afd0e1/cryptography-2.4.2.tar.gz (468kB)
    100% |████████████████████████████████| 471kB 3.2MB/s 
Collecting appdirs (from python-miio)
  Downloading https://files.pythonhosted.org/packages/56/eb/810e700ed1349edde4cbdc1b2a21e28cdf115f9faf263f6bbf8447c1abf3/appdirs-1.4.3-py2.py3-none-any.whl
Collecting construct (from python-miio)
  Downloading https://files.pythonhosted.org/packages/19/c0/f054941fa33d14378de66d2c0477d31f7ad97aa2e298a5771a7b20bc2039/construct-2.9.45.tar.gz (56kB)
    100% |████████████████████████████████| 61kB 12.2MB/s 
Collecting zeroconf (from python-miio)
  Downloading https://files.pythonhosted.org/packages/d2/4e/3e751bc1f33d0368bdba509a140cb9f2e54cd1cfb8ebcf4ebd8a5eef794b/zeroconf-0.21.3-py2.py3-none-any.whl
Collecting android-backup (from python-miio)
  Downloading https://files.pythonhosted.org/packages/01/bb/adfb293e9b74528b7cf4b5402fb1ee5507ae2bc4fe339b47e75c48dd5587/android_backup-0.2.0.tar.gz
Collecting pytz (from python-miio)
  Downloading https://files.pythonhosted.org/packages/61/28/1d3920e4d1d50b19bc5d24398a7cd85cc7b9a75a490570d5a30c57622d34/pytz-2018.9-py2.py3-none-any.whl (510kB)
    100% |████████████████████████████████| 512kB 3.1MB/s 
Collecting netifaces (from python-miio)
  Downloading https://files.pythonhosted.org/packages/0d/18/fd6e9c71a35b67a73160ec80a49da63d1eed2d2055054cc2995714949132/netifaces-0.10.9.tar.gz
Collecting attrs (from python-miio)
  Downloading https://files.pythonhosted.org/packages/3a/e1/5f9023cc983f1a628a8c2fd051ad19e76ff7b142a0faf329336f9a62a514/attrs-18.2.0-py2.py3-none-any.whl
Collecting idna>=2.1 (from cryptography->python-miio)
  Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
    100% |████████████████████████████████| 61kB 12.7MB/s 
Collecting asn1crypto>=0.21.0 (from cryptography->python-miio)
  Downloading https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl (101kB)
    100% |████████████████████████████████| 102kB 5.9MB/s 
Collecting six>=1.4.1 (from cryptography->python-miio)
  Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting cffi!=1.11.3,>=1.7 (from cryptography->python-miio)
  Downloading https://files.pythonhosted.org/packages/e7/a7/4cd50e57cc6f436f1cc3a7e8fa700ff9b8b4d471620629074913e3735fb2/cffi-1.11.5.tar.gz (438kB)
    100% |████████████████████████████████| 440kB 3.4MB/s 
    Complete output from command python setup.py egg_info:
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    Package 'libffi', required by 'virtual:world', not found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    Package 'libffi', required by 'virtual:world', not found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    Package 'libffi', required by 'virtual:world', not found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    Package 'libffi', required by 'virtual:world', not found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    Package 'libffi', required by 'virtual:world', not found
    
        No working compiler found, or bogus compiler options passed to
        the compiler from Python's standard "distutils" module.  See
        the error messages above.  Likely, the problem is not related
        to CFFI but generic to the setup.py of any Python package that
        tries to compile C code.  (Hints: on OS/X 10.8, for errors about
        -mno-fused-madd see http://stackoverflow.com/questions/22313407/
        Otherwise, see https://wiki.python.org/moin/CompLangPython or
        the IRC channel #python on irc.freenode.net.)
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-z5ukd19e/cffi/

I managed to solve the issue by installing a few packages using apk:

apk add gcc musl-dev python3-dev libffi-dev linux-headers

What I’m wondering is how much of this would sustain a container image update and container being created again?


#2

If everything for the plugin is installed in /config, it will survive a container updated, but I guess the python dependency is installed somewhere in the contaiener, so it will get lost on each container update.
You could make a script for adding the missing build dependencies and install the python plugin and the volume map it to /etc/cont.init.d/somenumber-name and it gets executed on container start.


#3

Thanks a lot @saarg, it works like a charm !
I managed to recreate the container and have it working.

For those who are interested, here is the content of my script:

#!/usr/bin/with-contenv bash

apk add --update gcc musl-dev python3-dev libffi-dev libressl-dev linux-headers

pip3 install -U python-miio