Page 2 of 8

Re: Python Plugin Beta testers - please read this

Posted: Saturday 21 January 2017 18:33
by ubee
@zaraki673,

You made my day! :D

My problems originated from the plugin.py~ file in the UniPIx folder! I deleted that file and then all plugins loaded succcessfully!

The plugin system is very sensitive and the error messages in the log file can be improved, to put it mildly....

Now I'm ready to proceed with my own plugin.

Btw, you don't need to build Domoticz from source. The pre-built beta version works fine!

Re: Python Plugin Beta testers - please read this

Posted: Sunday 22 January 2017 0:27
by Dnpwwo
@ubee,

Glad you are up and running but I can't reproduce this. My test plugins have other files in the folder and I even created a plugin.py~ that would fail the import but it still worked.

The plugin framework can only report what Python tells it and unfortunately it doesn't give much detail on import errors. For most other errors you will get a line number and sometimes a stack traceback so you should be over the hardest part.

Re: Python Plugin Beta testers - please read this

Posted: Sunday 22 January 2017 7:42
by korniza
@Dnpwwo can you provide a basic plugin template for a on/off switch and another for getting value of power (watt)? I try to build my test plugin but as far as I am not a coder, I just "copy and learn" how to build plugins.

Re: Python Plugin Beta testers - please read this

Posted: Sunday 22 January 2017 10:52
by zaraki673
@kornizca you can see this two switch in my plugin ;)

@Dnpwwo same issue to me, i can't put another file in my plugin folder :(

in my folder Awox, i put an empty file name toto.py, then my plugin don't run , and i only have that log :

Code: Select all

 Error: smp hardware (20) thread seems to have ended unexpectedly

Re: Python Plugin Beta testers - please read this

Posted: Sunday 22 January 2017 11:50
by zak45
I'm testing in W10.

Installed PY 3.6 for win and have this on Domoticz log : 2017-01-22 11:22:36.285 PluginSystem: Started, Python version '3.6.0'. --> great
Created the Kodi directory and put the 1.0.2 version on it : C:\Program Files (x86)\Domoticz\plugins\Kodi\plugin.py
I'm able to see 'Kodi Players' on the HW page --> ok

Kodi device created but have this error on my log file :

2017-01-22 11:45:50.923 (Kodic) initialized
2017-01-22 11:45:50.964 (Kodic) Devices created.
2017-01-22 11:45:50.965 PluginSystem: Starting I/O service thread.
2017-01-22 11:45:51.067 Error: (Kodic) 'onConnect' failed 'TypeError':'onConnect() missing 2 required positional arguments: 'Status' and 'Description''.

and every 30 seconds :

2017-01-22 11:46:17.427 (AeonStick) Light/Switch (Z-FenetreCuisineMvt)
2017-01-22 11:46:20.512 Error: CPlugin:PyDomoticz_Connect, connection request from 'Kodic' ignored. Transport is already connected.
2017-01-22 11:46:30.397 (RFX433E) Temp + Humidity (433-TempSDB)
2017-01-22 11:46:44.839 (RFX433E) Temp + Humidity (433-TempSDBE)
2017-01-22 11:46:45.750 (RFX433E) Temp + Humidity (433-TempSalon)
2017-01-22 11:46:47.333 (RFX433E) Temp + Humidity (433-TempExt)
2017-01-22 11:46:50.523 Error: CPlugin:PyDomoticz_Connect, connection request from 'Kodic' ignored. Transport is already connected.

and some others if I click on a device :

2017-01-22 11:47:29.042 (AeonStick) Light/Switch (Z-FenetreCuisineMvt)
2017-01-22 11:47:48.234 CLuaHandler (updateDevice from LUA) : idx=42 nvalue=1 svalue=De11h50 à 12h50 : Pas de précipitations invalue=1 signallevel=12 batterylevel=255
2017-01-22 11:47:49.036 User: Admin initiated a switch command (639/Kodic - Source/Set Level)
2017-01-22 11:47:49.043 Error: (Kodic) Kodi can not be turned on, No MAC address configured.
2017-01-22 11:47:50.603 Error: CPlugin:PyDomoticz_Connect, connection request from 'Kodic' ignored. Transport is already connected.


please advise.
thanks a lot for your work!

Re: Python Plugin Beta testers - please read this

Posted: Monday 23 January 2017 10:26
by kalinkamaen
Is this possible in windows version also? I cant find the Domoticz/plugins folder.
And i cant fin much info about how to do this!

Re: Python Plugin Beta testers - please read this

Posted: Monday 23 January 2017 12:47
by Dnpwwo
@zak45,

The plugin framework is still in beta so the interface changes sometimes. Try the last version I posted, that may work better viewtopic.php?f=4&t=15233&p=114933#p114782

@kalinkamaen,

The framework runnings on linux and windows, you can create the plugins folder if it is not there and drop the plugin in a Kodi folder and it should work.

Look in your Domoticz log at startup, if the plugin system finds Python and starts then the plugins will work.

Re: Python Plugin Beta testers - please read this

Posted: Monday 23 January 2017 14:19
by kalinkamaen
Hello sir. Thank you for quick answear.
I have windows 10, and installed python 3.6.
As I understand, Domoticz does not see my Python. What is the trick do make domoticz
see it?

Here is what my log file give me:
2017-01-23 14:18:55.130 PluginSystem: Failed dynamic library load, install the latest libpython3.x library that is available for your platform.

Re: Python Plugin Beta testers - please read this

Posted: Monday 23 January 2017 14:27
by Dnpwwo
@kalinkamaen,

I have only tried Python 3.5 so I haven't seen the Windows 3.6 installer. For 3.5 I described the install here: viewtopic.php?f=41&t=7098&start=220#p110486.

There is no reason why 3.6 shouldn't work though, I believe the important thing is to check the 'Add Python 3.x to PATH' option, this allows other programs to find it.

Re: Python Plugin Beta testers - please read this

Posted: Monday 23 January 2017 16:14
by kalinkamaen
Thanks, that helped, Now I need to find out how the sonos plugin works :)

Re: Python Plugin Beta testers - please read this

Posted: Monday 23 January 2017 21:36
by zak45
tested 1.0.2 again, unfortunately same result :

2017-01-23 21:34:02.382 (Kodic) initialized
2017-01-23 21:34:02.418 (Kodic) Devices created.
2017-01-23 21:34:02.418 PluginSystem: Starting I/O service thread.
2017-01-23 21:34:03.726 Error: (Kodic) 'onConnect' failed 'TypeError':'onConnect() missing 2 required positional arguments: 'Status' and 'Description''.
2017-01-23 21:34:08.082 (RFX433E) Temp + Humidity (433-TempSalon)
2017-01-23 21:34:31.942 PluginSystem: Starting I/O service thread.
2017-01-23 21:34:33.249 Error: (Kodic) 'onConnect' failed 'TypeError':'onConnect() missing 2 required positional arguments: 'Status' and 'Description''.
2017-01-23 21:34:34.423 (RFX433E) Temp + Humidity (433-TempSDB)

Re: Python Plugin Beta testers - please read this

Posted: Tuesday 24 January 2017 10:23
by Dnpwwo
@zak45,

This still looks like you don't have the correct code running. Have a look at plugin.py in the Kodi folder and make sure that line 78 looks like this:

Code: Select all

def onConnect(Status, Description):
If not then you have the wrong file, if it does then go to the Hardware page, select the Kodi plugin and hit the 'Update' button to force a reload.

Re: Python Plugin Beta testers - please read this

Posted: Tuesday 24 January 2017 10:53
by CaptainSlow
Probably a noob remark. I'm on rasp pi 3 with domticz beta. I don't use plugins yet but in the log I see this:

Code: Select all

PluginSystem: Failed dynamic library load, install the latest libpython3.x library that is available for your platform.

Re: Python Plugin Beta testers - please read this

Posted: Tuesday 24 January 2017 13:23
by zak45
@Dnpwwo:
thanks for the answer;
Have tested by removing all devices/HW related to Kodi.
On my .py file on line 79 (not 78 ?) I have seen the two param:

Code: Select all

    else:
        if (1 in Devices): playerState = Devices[1].nValue
        if (2 in Devices): mediaLevel = Devices[2].nValue
    DumpConfigToLog()
    Domoticz.Transport("TCP/IP", Parameters["Address"], Parameters["Port"])
    Domoticz.Protocol("JSON")
    Domoticz.Heartbeat(10)
    Domoticz.Connect()
    return True

def onConnect(Status, Description):
    global isConnected, playerState
Do not know what to do more !?

Re: Python Plugin Beta testers - please read this

Posted: Tuesday 24 January 2017 20:39
by zaraki673
zaraki673 wrote:@kornizca you can see this two switch in my plugin ;)

@Dnpwwo same issue to me, i can't put another file in my plugin folder :(

in my folder Awox, i put an empty file name toto.py, then my plugin don't run , and i only have that log :

Code: Select all

 Error: smp hardware (20) thread seems to have ended unexpectedly

@Dnpwwo, i can now put other librairies file in the plugin's folder ...

Re: Python Plugin Beta testers - please read this

Posted: Tuesday 24 January 2017 23:07
by ubee
@zaraki673,

I have had a few days brake, and now I'm back again trying to write my own plugin for a UniPI board. I created a new plugin directory UniPIx and put a modified copy of your AwoxSMP in that directory. And all of a sudden I'm back again with the old problem. No plugins will load. This time I don't have any extra files in any of the two plugin directories. You notice when the import fails. In that case the new hardware plugins pop up at the end of the HW list and you are not able to create any of those hardware devices. If the import works, the new hardware will show up in alphabetical order in the drop down list.

Just to make sure my UniPIx plugin does not cause the problem, I removed that directory completely. The only plugin left is your AwoxSMP plugin, original version. But still the import fails! No info available in the log file. The last lines in the log file looks as follows:
  • 2017-01-24 22:40:40.437 PluginSystem: Entering work loop.
    2017-01-24 22:40:42.244 Incoming connection from: 192.168.1.132
    2017-01-24 22:40:43.153 Hardware Monitor: Fetching data (System sensors)
So now I'm stuck again. With just your plugin that worked a few days ago and it is untouched. And no extra files in the directory. This is quite frustrating to be honest... :? :cry:

Re: Python Plugin Beta testers - please read this

Posted: Wednesday 25 January 2017 12:13
by Dnpwwo
@ubee,

I don't know what the problems are but my next merge will try and help. I have changed the logging around import errors to be more useful and have reviewed the code that loads plugin details and restricted the files that it looks in to improve robustness.

Hoping to create a pull request this weekend but I'm waiting a few days while the revised code runs continuously on my Pi to make sure that I haven't introduced any instability.

Re: Python Plugin Beta testers - please read this

Posted: Wednesday 25 January 2017 13:04
by ubee
@Dnpwwo,

Thanks for your support. It's not so urgent, but I look forward to get the new code once it is available. Btw, I replaced the AwoxSMP with your Kodi plugin. Also untouched and just this plugin. No other. This import also fails silently. And the Kodi player pops up at the end of the drop down list. So the plugin system finds the file, can read the header and populates the HW drop down data set. Then nothing more happens.

Something has gone wrong. It worked fine a couple of days ago, and I have not made any changes since then...Sounds like a variable that has not been initiated, and content is a bit stochastic.

Re: Python Plugin Beta testers - please read this

Posted: Wednesday 25 January 2017 17:26
by ubee
@Dnpwwo,

The import works after reboot! Domoticz service restart is not enough. The question is why. I guess service restart should be enough.

Re: Python Plugin Beta testers - please read this

Posted: Thursday 26 January 2017 23:21
by ffes
I want experiment with writing a plugin in python, but I also see the error message in my log:

Code: Select all

PluginSystem: Failed dynamic library load, install the latest libpython3.x library that is available for your platform.
I have done "apt install python3" and "python3" from the command line works as expected.

Code: Select all

pi@domoticz:~ $ python3
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
pi@domoticz:~ $
Did I miss anything else?