[Domoticz 2020.2] add python plugins (how-to)

home automation

Moderator: Lillian.W@AST

Post Reply
User avatar
father.mande
Posts: 1810
youtube meble na wymiar Warszawa
Joined: Sat Sep 12, 2015 2:55 am
Location: La Rochelle (France)

[Domoticz 2020.2] add python plugins (how-to)

Post by father.mande »

Hi,

As response to private message ... please find here after indication to add plugin in Domoticz 2020.2 (based on Ubuntu 20.04 L.T.S. (aka focal)
==== Domoticz APKG is delivered as is ... without elements to add plugins ... because, plugins require a minimum of Linux knowledge (very few) ... but it's easy to get it. :D

I use as an example the google plugin ... but it's just theoretically ...
==== ALL is identical (if not explicitly write) for ALL models and architecture
==== all command MUST be run in a ssh terminal using root/your_admin_password for connection (NOT admin)
Phase 1 : ONLY for X86_64 architecture to do one except if update overwrite uname
... due to a malformed kernel version ... you need (temporary up to my next update) to create a workaround
... THIS IS MANDATORY ONLY if result of uname -r is "4.14.x" and if uname -m is "x86_64"
==== thanks to Nazar78 that simplify my multi-lines version (managing only -r) :D ... this is based on its own version of corrected uname
cd /usr/local/AppCentral/domoticz/focal_x86_64/bin
mv uname uname.asustor
echo -e '#!/bin/sh\n\n/bin/uname.asustor "$@"'"|sed 's/\\.x/\\.187/g'">uname
chmod +x uname

... to test it, enter in domoticz Ubuntu env. and run uname -a

Code: Select all

# domoticz_mngt enter_in_ubuntu
root@AS5002TAPHIL:/# uname -a
Linux AS5002TAPHIL 4.14.187 #1 SMP Wed Aug 12 00:30:36 CST 2020 x86_64 x86_64 x86_64 GNU/Linux
root@AS5002TAPHIL:/# exit
exit
/#
... .187 is displayed in place of .x in kernel version 187 is the last 4.14 I use for kernel modules ... due to error in some intermediate 4.14 version

Phase 2 (ALL platform): (to do one time)
... do an update / upgrade to get the last version of libraries and security fix
domoticz_mngt update_ubuntu
... install missing sudo (for domoticz internal script) MUST be added in next APKG version (sorry for this error)
domoticz_mngt enter_in_ubuntu
apt-get install sudo


Phase 3 (ALL platform) but depend of the plugin you want to install
... GET prerequisite for plugin ... BEST is to read the documentation associated (here : https://github.com/dnpwwo/Domoticz-Google-Plugin )
... in the google plugin ... this require : pip3 ; pychromecast and gtts python3 modules and git for install
... install the required software and in python3 the modules using pip3
install pip3 and upgrade to last version

Code: Select all

# apt-get install python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libpython3-dev python-pip-whl python3-dev python3-distutils python3-lib2to3 python3-pkg-resources python3-setuptools
  python3-wheel python3.8-dev zlib1g-dev
Suggested packages:
  python-setuptools-doc
The following NEW packages will be installed:
  libpython3-dev python-pip-whl python3-dev python3-distutils python3-lib2to3 python3-pip python3-pkg-resources
  python3-setuptools python3-wheel python3.8-dev zlib1g-dev
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,405 kB of archives.
After this operation, 7,785 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://fr.archive.ubuntu.com/ubuntu focal/main amd64 python3-pkg-resources all 45.2.0-1 [130 kB]
Get:2 http://fr.archive.ubuntu.com/ubuntu focal/main amd64 libpython3-dev amd64 3.8.2-0ubuntu2 [7,236 B]
... ... ...
Setting up python3.8-dev (3.8.2-1ubuntu1.2) ...
Setting up python3-dev (3.8.2-0ubuntu2) ...
root@AS5002TAPHIL:/# pip3 install --upgrade pip
Collecting pip
  Downloading pip-20.2.2-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 2.5 MB/s
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.0.2
    Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
    Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-20.2.2
root@AS5002TAPHIL:/# pip3 -V
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
root@AS5002TAPHIL:/#
... NOW install python modules using pip (as it is documented) : pychromecast and gtts

Code: Select all

# pip3 install pychromecast
Collecting pychromecast
  Downloading PyChromecast-7.2.0-py2.py3-none-any.whl (56 kB)
     |████████████████████████████████| 56 kB 406 kB/s
Collecting casttube>=0.2.0
  Downloading casttube-0.2.1-py3-none-any.whl (6.5 kB)
Collecting requests>=2.0
  Downloading requests-2.24.0-py2.py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 39 kB/s
Collecting zeroconf>=0.25.1
  Downloading zeroconf-0.28.1-py3-none-any.whl (51 kB)
     |████████████████████████████████| 51 kB 18 kB/s
Collecting protobuf>=3.0.0
  Downloading protobuf-3.13.0-cp38-cp38-manylinux1_x86_64.whl (1.3 MB)
     |████████████████████████████████| 1.3 MB 12.5 MB/s
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Downloading urllib3-1.25.10-py2.py3-none-any.whl (127 kB)
     |████████████████████████████████| 127 kB 12.1 MB/s
Collecting idna<3,>=2.5
  Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 939 kB/s
Collecting chardet<4,>=3.0.2
  Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB)
     |████████████████████████████████| 133 kB 11.5 MB/s
Collecting certifi>=2017.4.17
  Downloading certifi-2020.6.20-py2.py3-none-any.whl (156 kB)
     |████████████████████████████████| 156 kB 9.6 MB/s
Collecting ifaddr>=0.1.7
  Downloading ifaddr-0.1.7-py2.py3-none-any.whl (10 kB)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from protobuf>=3.0.0->pychromecast) (45.2.0)
Collecting six>=1.9
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: urllib3, idna, chardet, certifi, requests, casttube, ifaddr, zeroconf, six, protobuf, pychromecast
Successfully installed casttube-0.2.1 certifi-2020.6.20 chardet-3.0.4 idna-2.10 ifaddr-0.1.7 protobuf-3.13.0 pychromecast-7.2.0 requests-2.24.0 six-1.15.0 urllib3-1.25.10 zeroconf-0.28.1
root@AS5002TAPHIL:/# pip3 install gtts
Collecting gtts
  Downloading gTTS-2.1.1-py3-none-any.whl (25 kB)
Requirement already satisfied: requests in /usr/local/lib/python3.8/dist-packages (from gtts) (2.24.0)
Collecting beautifulsoup4
  Downloading beautifulsoup4-4.9.1-py3-none-any.whl (115 kB)
     |████████████████████████████████| 115 kB 6.1 MB/s
Requirement already satisfied: six in /usr/local/lib/python3.8/dist-packages (from gtts) (1.15.0)
Collecting gtts-token>=1.1.3
  Downloading gTTS-token-1.1.3.tar.gz (3.4 kB)
Collecting click
  Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
     |████████████████████████████████| 82 kB 143 kB/s
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.8/dist-packages (from requests->gtts) (2020.6.20)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.8/dist-packages (from requests->gtts) (2.10)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.8/dist-packages (from requests->gtts) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.8/dist-packages (from requests->gtts) (1.25.10)
Collecting soupsieve>1.2
  Downloading soupsieve-2.0.1-py3-none-any.whl (32 kB)
Building wheels for collected packages: gtts-token
  Building wheel for gtts-token (setup.py) ... done
  Created wheel for gtts-token: filename=gTTS_token-1.1.3-py3-none-any.whl size=4097 sha256=419be14115ad95f9cc0a709c4480ef6bf85660b5fa2509709c29f53edad77500
  Stored in directory: /root/.cache/pip/wheels/95/85/5d/7ee5fb054f35d52211e9274275d76f29f0a484f42876579596
Successfully built gtts-token
Installing collected packages: soupsieve, beautifulsoup4, gtts-token, click, gtts
Successfully installed beautifulsoup4-4.9.1 click-7.1.2 gtts-2.1.1 gtts-token-1.1.3 soupsieve-2.0.1
... now install git (if not already done) require by THIS plugin ... even downloading is enough ... but another debate ...

Code: Select all

# apt-get install git
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  git-man less libbsd0 libcbor0.6 libedit2 liberror-perl libfido2-1 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6
  libxmuu1 openssh-client xauth
Suggested packages:
  gettext-base git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn
  keychain libpam-ssh monkeysphere ssh-askpass
The following NEW packages will be installed:
  git git-man less libbsd0 libcbor0.6 libedit2 liberror-perl libfido2-1 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6
  libxmuu1 openssh-client xauth
0 upgraded, 17 newly installed, 0 to remove and 0 not upgraded.
Need to get 7,274 kB of archives.
After this operation, 47.1 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://fr.archive.ubuntu.com/ubuntu focal-updates/main amd64 less amd64 551-1ubuntu0.1 [123 kB]
Get:2 http://fr.archive.ubuntu.com/ubuntu focal/main amd64 libbsd0 amd64 0.10.0-1 [45.4 kB]
... ... ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...
Processing triggers for mime-support (3.64ubuntu1) ...
root@AS5002TAPHIL:/#
==== NOW all prerequisite are installed ... follow the procedure

cd /opt/domoticz/plugins
git clone https://github.com/dnpwwo/Domoticz-Google-Plugin.git

... do verification documented (in my case it's not as documented ... not only a plugin.py and icons BUT a folder : Domoticz-Google-Plugin/ and zip containing icons ???? ) need to be tested
... ... I can't test ... I am at 600 kms of my NAS :mrgreen:
... restart domoticz
/etc/init.d/domoticz.sh restart
... OR exit ubuntu (exit) and use AppCentral to disable / enable domoticz

run tests and return log in case of problems ... even domoticz forum or github is more appropriate for a good support (said ... you run in Ubuntu 20.04 L.T.S (focal)) if your platform is require.

Philippe.
AS6602T / AS5202T /AS5002T / AS1002T / FS6706T
Post Reply

Return to “Domoticz”