Compiling the REST plugin for device specific testing - dresden-elektronik/deconz-rest-plugin GitHub Wiki
Adding support for new devices can be cumbersome and tidious, depending on the device if done remotely by a developer. Also, adding new features or resolution of certain rare bugs should ideally be tested upfront before finding its way into the mater branch and becomming available for all. In such cases, a developer might ask to compile a specific version of the REST plugin containing only the changes relevant for the given purpose. The following should give guidance on how to compile and test an amended REST plugin. Prerequisite (as of writing this) is availability of a bare Linux OS (e.g. RasbianOS or Ubuntu) and a Conbee 1/2. Additionally, the developer shall provide the URL to his repository and the corresponding branch to use.
-
Switch to deCONZ beta APT-Repository (see also https://phoscon.de/de/conbee2/install#raspbian)
sudo sh -c "echo 'deb http://phoscon.de/apt/deconz $(lsb_release -cs)-beta main' > /etc/apt/sources.list.d/deconz.list"
-
Update APT sources
sudo apt-get update
-
Install deCONZ latest beta and dev package
sudo apt-get install deconz deconz-dev
-
Make a backup of the untouched plugin to the users home directory
sudo cp /usr/share/deCONZ/plugins/libde_rest_plugin.so ~/bak_libde_rest_plugin.so
-
Clone the code from the developer's repository with the given branch. The basic command for this purpose is:
git clone --branch=<BRANCHNAME> <REPOSITORY_URL> <FOLDER_NAME>
For simplicity, we always use the name of the branch as folder name. Assuming branchtest
and repository URLhttps://github.com/swoopx/deconz-rest-plugin.git
are provided, use the following command:
git clone --branch=test https://github.com/swoopx/deconz-rest-plugin.git test
-
Change to the newly created folder and compile, you can remove the -j2 flag on weak machine (can freeze Pi3 for exemple)
cd ./test
qmake && make -j2
-
Recall how deCONZ is running (with or without GUI) and use the corresponding command to stop deCONZ service (in doubt, execute both commands)
GUI mode:sudo systemctl stop deconz-gui
Headless mode:sudo systemctl stop deconz
-
Copy the compiled plugin to the required folder
sudo cp ../libde_rest_plugin.so /usr/share/deCONZ/plugins/
-
Restart deCONZ according to your preferred running mode
GUI mode:sudo systemctl start deconz-gui
Headless mode:sudo systemctl start deconz
In case the developer has asked for some debug output, the following is recommended
GUI mode:/usr/bin/deCONZ --dbg-info=2 --dbg-error=2 > test_debug
Headless mode:/usr/bin/deCONZ --platform minimal --dbg-info=2 --dbg-error=2 > test_debug
Please note this creates a file namedtest_debug
in the folder where you executed the above command. It should be shared with the developer to progress further. -
(Optional) Once done with testing and you prefer to not use the test plugin any longer or in case any error occur, restore the plugin backup
Kill the running process withCTRL+C
if taking debug logs or stop the service as described in step 7 and restore the plugin.
sudo cp ~/bak_libde_rest_plugin.so /usr/share/deCONZ/plugins/libde_rest_plugin.so
Note
If you are using docker, you can take a look here https://github.com/franciscogouveia/docker-deconz-rest-plugin-test
For exemple
git clone https://github.com/franciscogouveia/docker-deconz-rest-plugin-test.git
cd docker-deconz-rest-plugin-test
docker pull marthoc/deconz
docker build -t my-deconz-image --build-arg PLUGIN_REPOSITORY=https://github.com/XXXX/deconz-rest-plugin.git --build-arg PLUGIN_GIT_COMMIT=special_branch .