Page 1 of 8
Python Plugin Beta testers - please read this
Posted: Wednesday 04 January 2017 2:48
by Dnpwwo
The next beta will change the location of the plugins so when you see failures during startup you will need to move them.
Plugins are being moved into their own directories to allow for future requirements when plugins ship with multiple files or have things like icons associated with them.
Rather than being in the
directory directly they need to be a level lower. For example if you are playing with @tester22 Sonos plugin you need to move the Sonos.py file in a directory like
Apologies for any inconvenience.
Re: Python Plugin Beta testers - please read this
Posted: Wednesday 04 January 2017 16:24
by gizmocuz
Well it's still beta, anything can/will change

Re: Python Plugin Beta testers - please read this
Posted: Wednesday 04 January 2017 16:34
by deennoo
About plugin :
As this an open source project, and we can help by developping plugin ourself i got a question to Gizmocuz.
Is this possible to retrive rgb color with plugin ?
idea is to made a milightv6 plugin (yes again and again about it...but now we got a start of something with a python script who works but need to be improved :
https://github.com/bwydoogh/domoticz-scripts)
Re: Python Plugin Beta testers - please read this
Posted: Wednesday 04 January 2017 16:38
by gizmocuz
I think we should first have the plugin system working as we(Dnpwwo) want... then see how we can extend things.
At the moment, i think only nValue/sValue's can be used
Re: Python Plugin Beta testers - please read this
Posted: Friday 13 January 2017 14:47
by MildaGenius
Testing beta 3.6343 version with Kodi plugin (/home/domoticz/domoticz/plugins/Kodi/Kodi.py).
In log I can see:
Code: Select all
PluginSystem: Started, Python version '3.4.2'.
PluginSystem: Entering work loop.
So its look good, but after I open hardware webpage error in log appears.
Code: Select all
Error: PluginList: Error 'Error document empty.' at line 0 column 0 in XML ''.
And Kodi Player hardware is not in hardware list

.
PS: Will be great to mentioned on Python hardware wiki page, that python plugin is only in beta version

.
Re: Python Plugin Beta testers - please read this
Posted: Friday 13 January 2017 16:57
by deennoo
As this fonction is only aviable on beta version...
Re: Python Plugin Beta testers - please read this
Posted: Tuesday 17 January 2017 10:11
by MildaGenius
So, nobody else has this error?
Code: Select all
Error: PluginList: Error 'Error document empty.' at line 0 column 0 in XML ''.
Re: Python Plugin Beta testers - please read this
Posted: Tuesday 17 January 2017 15:46
by ubee
I'm interested to write my own Python plugin for a specific HW. I have tried to install a few of the sample scripts just to see if they pop-up in the drop-drown list on the HW config page. So far I have not manage to see any of those.
Reading this thread I get the impression I need to have a beta version of Domoticz to try-out Python plug-ins. Right now I'm running 3.4834. If I need a new version, where do I find it?
Re: Python Plugin Beta testers - please read this
Posted: Tuesday 17 January 2017 16:04
by deennoo
On linux or windows ?
Best is to run a vm with debian and compile domoticz from source following this :
https://www.domoticz.com/wiki/Linux
Re: Python Plugin Beta testers - please read this
Posted: Tuesday 17 January 2017 21:19
by ubee
On Linux (Rasp w. Raspbian). I realize I have to spend some time on this... Wonder how long it will take before this is supported by the prebuild versions? Or is Python plugins alreade supported in the beta version available for download?
Thanks anyway for your answer.
Re: Python Plugin Beta testers - please read this
Posted: Tuesday 17 January 2017 21:38
by Dnpwwo
@MildaGenius,
It is still beta but if you want to have a look at it
Testing beta 3.6343 version with Kodi plugin (/home/domoticz/domoticz/plugins/Kodi/Kodi.py).
The file needs to /home/domoticz/domoticz/plugins/Kodi/plugin.py
Depending on the version it may complain about the number of parameters in the log, if so try the updated version
Re: Python Plugin Beta testers - please read this
Posted: Tuesday 17 January 2017 21:49
by ubee
Ok, I updated my question at the same time as you came with this answer. My understanding is python plugin is supported in 3.6343 beta version, and I can just download the pre-built version to my Rasp.
Re: Python Plugin Beta testers - please read this
Posted: Wednesday 18 January 2017 14:08
by ubee
Hm, I have "upgraded" to the latest beta version, and domoticz deamon starts including Plugin system (can see that in the log file). However, for some reason the webserver indicates "Domoticz offline" and I can´t figure out why. I haven't changed any ports or anything else in the init.d script. So right now it's a bit difficult to continue with my real mission; investigate the python plugin support....
Edit: Problem solved. I forgot I have changed Rasp and hence have to use a different port.....
Re: Python Plugin Beta testers - please read this
Posted: Wednesday 18 January 2017 21:32
by MildaGenius
Ok, after rename plugin name to "plugin.py" I can see Kodi and my plugin too in hadware list.
Thanks for hint and for developing this framework.
Re: Python Plugin Beta testers - please read this
Posted: Thursday 19 January 2017 15:26
by ubee
I´m struggling to come to a point where I can start do some coding on my own plugin. But is seems like I have some basic problem with my environment. I have Domoticz 3.6371 beta up and running and I have made a very clean plugin based on the generic template for plugins. No parameters and just the domoticz.log statements in the call back functions. I thought I should be able to see some output in the log file when I add a new hardware of this type. The hardware pops up in the Type dropdown. But if I select this, give it a name and push "Add" nothing happens. No new hardware show up in the table, and no trace of this operation in the log file.
Then I tried to add the Kodi plugin.py enclosed in an earlier post. With this installed I can add a Kodi player, and the hardware pops up in the table. However, the log file shows the following error:
- 2017-01-19 15:05:17.854 Domoticz V3.6371 (c)2012-2017 GizMoCuz
2017-01-19 15:05:17.855 Build Hash: d7773f7, Date: 2017-01-16 12:02:11
2017-01-19 15:05:17.855 System: Raspberry Pi
2017-01-19 15:05:17.855 Startup Path: /home/pi/domoticz/
Sunrise: 08:37:00 SunSet:16:06:00
EventSystem: reset all events...
PluginSystem: Started, Python version '3.4.2'.
Active notification Subsystems: (0/12)
WebServer(HTTP) started on address: :: with port 8085
WebServer(SSL) started on address: :: with port 443
Proxymanager started.
Starting shared server on: :::6144
TCPServer: shared server started...
RxQueue: queue worker started...
GPIO: WiringPi is now initialized
GPIO: Worker started...
Hardware Monitor: Started
EventSystem: reset all events...
EventSystem: reset all device statuses...
EventSystem: Started
PluginSystem: Entering work loop.
Hardware Monitor: Fetching data (System sensors)
Hardware Monitor: Fetching data (System sensors)
Incoming connection from: 192.176.1.81
Hardware Monitor: Fetching data (System sensors)
Error: () failed to load, Path '/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
Error: (Kodi player) Module Import failed, exception: 'ImportError'
Error: (Kodi player) Module Import failed: ' Name: plugin'
Hardware Monitor: Fetching data (System sensors)
Something is wrong, I need some help to reach a point from where I can start moving forward.....

Re: Python Plugin Beta testers - please read this
Posted: Friday 20 January 2017 2:06
by Dnpwwo
@ubee,
Hard to be sure without seeing your Python but I had a problem with the same symptoms myself earlier this week. Check the alignment with the guidance on the wiki around the key value. The key value is used in the HTML of the Hardware page, this means that if you put some characters in it you can get the behavior you are seeing because the HTML is invalid so the Add function fails. I created a test plugin and used a key="HTML 1.1" which did not work but key="HTML_1-1" did.
Unique identifier for the plugin. Never visible to users this should be short, meaningful and made up of characters A-Z, a-z, 0-9 and -_ only. Stored in the ‘Extra’ field in the Hardware. Used as the base name for the plugin Python file, e.g. ‘DenonAVR’ maps to /plugins/DenonAVR/plugin.py
Import errors are normally because the file is not found so check that the folder and file are named correctly. If Domoticz finds the file but does not like it you will get different errors that will tell you why.
Re: Python Plugin Beta testers - please read this
Posted: Friday 20 January 2017 9:41
by ubee
Ok, I'm talking about your (@Dnpwwo) Kodi module you provided in earlier in this thread. I haven't changed one letter in this file, and just stored in plugins/Kodi, i.e. /home/pi/domoticz/plugins/Kodi/plugin.py. Still the import fails. I will try the trick described by @zaraki673 in
viewtopic.php?f=4&t=15567, I mean manually import the file and then copy the file to /usr/lib/python3.4/
Edit: Misunderstood @zaraki673. He is not referring to the plugin module, but a library. Still no progress. I can't load the Kodi plugin. I have to get this up and running before I continue with my own. From the log I get the feeling I miss essential python libraries, and the makes the import of the Kodi plugin fail.
- Error: () failed to load, Path '/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
Error: (Kodi player) Module Import failed, exception: 'ImportError'
Error: (Kodi player) Module Import failed: ' Name: plugin'
Re: Python Plugin Beta testers - please read this
Posted: Saturday 21 January 2017 2:29
by zaraki673
Hi,
Where can we post our plugin on the forum?
I write one for
Awox Smartplug
I put it here for the moment,
You need to install
bluepy and copy or symlink install path like that :
Code: Select all
sudo cp -r /usr/local/lib/python3.4/dist-packages/bluepy/ /usr/lib/python3.4/
or
Code: Select all
sudo ln -s /usr/local/lib/python3.4/dist-packages/bluepy /usr/lib/python3.4/bluepy
(i hope i'm right

)
i find code to control SmartPlug here :
https://github.com/sourceperl/smartplugctl
Re: Python Plugin Beta testers - please read this
Posted: Saturday 21 January 2017 12:13
by ubee
I'm almost desparate now...

. I haven't managed to load one single plugin and I have tried with the Kodi player, Awox plugin, RAVEn plugin .... No sucess. The file names and directories are correct as far as I understand:
- pi@raspberrypi:~/domoticz $ ls -lR plugins
plugins:
totalt 16
drwxr-xr-x 2 pi pi 4096 jan 21 11:32 AwoxSMP
drwxr-xr-x 2 pi pi 4096 jan 18 15:50 Kodi
drwxr-xr-x 2 pi pi 4096 jan 18 15:50 RAVEn
drwxr-xr-x 2 pi pi 4096 jan 19 07:55 UniPIx
plugins/AwoxSMP:
totalt 8
-rw-r--r-- 1 pi pi 6808 jan 21 11:31 plugin.py
plugins/Kodi:
totalt 32
-rwxrwxrwx 1 pi pi 28857 jan 14 14:31 plugin.py
plugins/RAVEn:
totalt 12
-rwxr-xr-x 1 pi pi 10292 jan 18 15:50 plugin.py
plugins/UniPIx:
totalt 8
-rw-r--r-- 1 pi pi 2561 jan 19 14:32 plugin.py
-rw-r--r-- 1 pi pi 2583 jan 18 15:50 plugin.py~
The UniPIx is my own attempt to develop a plugin. All others are untouched. The plugin system is running according to the log file, but the import fails. Is it mandatory to build Domoticz from source to make it work? I thought the pre-built beta should work. And I have installed all libraries described in the build instruction to make sure I have everything in place.
The plugins show up in the HW drop-in list, which indicates Domoticz finds the files and can read the XML headers. But I can´t create any HW and the log shows import errors for the Kodi plugin. ??????
Re: Python Plugin Beta testers - please read this
Posted: Saturday 21 January 2017 14:44
by zaraki673
Hi Ubee,
To make Plugins Working, I install a new Domoticz Server on a Pi3, i just follow wiki to install Domoticz from source.
And then try with just Kodi players plugins, when this one was ok, I add mine.
The Plugins Framework don't like if we put another file in the directory of the plugin
(When i add a .Py librairie in the same folder as the plugin.py file)
Hope i help you
(send me your plugin, I could try it and see problem don't come from it

)