Python Plugin Beta testers - please read this

Python and python framework

Moderator: leecollings

ubee
Posts: 66
Joined: Tuesday 10 February 2015 20:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Sweden
Contact:

Re: Python Plugin Beta testers - please read this

Post 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!
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python Plugin Beta testers - please read this

Post 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.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
korniza
Posts: 157
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6028
Location: Greece
Contact:

Re: Python Plugin Beta testers - please read this

Post 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.
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
zaraki673
Posts: 32
Joined: Thursday 19 January 2017 23:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Python Plugin Beta testers - please read this

Post 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
zak45
Posts: 953
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugin Beta testers - please read this

Post 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!
kalinkamaen
Posts: 52
Joined: Sunday 04 January 2015 15:57
Target OS: Windows
Domoticz version: 2022.2
Location: Norway
Contact:

Re: Python Plugin Beta testers - please read this

Post 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!
Windows 10, Domoticz 14784
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python Plugin Beta testers - please read this

Post 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.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
kalinkamaen
Posts: 52
Joined: Sunday 04 January 2015 15:57
Target OS: Windows
Domoticz version: 2022.2
Location: Norway
Contact:

Re: Python Plugin Beta testers - please read this

Post 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.
Windows 10, Domoticz 14784
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python Plugin Beta testers - please read this

Post 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.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
kalinkamaen
Posts: 52
Joined: Sunday 04 January 2015 15:57
Target OS: Windows
Domoticz version: 2022.2
Location: Norway
Contact:

Re: Python Plugin Beta testers - please read this

Post by kalinkamaen »

Thanks, that helped, Now I need to find out how the sonos plugin works :)
Windows 10, Domoticz 14784
zak45
Posts: 953
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugin Beta testers - please read this

Post 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)
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python Plugin Beta testers - please read this

Post 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.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
CaptainSlow
Posts: 60
Joined: Thursday 08 December 2016 21:07
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Bussum
Contact:

Re: Python Plugin Beta testers - please read this

Post 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.
____________________________________________________________________
Raspberry PI 3 Model B with USB stick, Domoticz Stable, OTGW LAN with ESP wifi-bridge and Isense Thermostat using the Outside Temp from Buienradar via Domoticz, Milight Ibox-2(V6)
zak45
Posts: 953
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugin Beta testers - please read this

Post 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 !?
zaraki673
Posts: 32
Joined: Thursday 19 January 2017 23:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Python Plugin Beta testers - please read this

Post 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 ...
ubee
Posts: 66
Joined: Tuesday 10 February 2015 20:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Sweden
Contact:

Re: Python Plugin Beta testers - please read this

Post 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:
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python Plugin Beta testers - please read this

Post 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.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
ubee
Posts: 66
Joined: Tuesday 10 February 2015 20:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Sweden
Contact:

Re: Python Plugin Beta testers - please read this

Post 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.
ubee
Posts: 66
Joined: Tuesday 10 February 2015 20:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Sweden
Contact:

Re: Python Plugin Beta testers - please read this

Post 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.
ffes
Posts: 51
Joined: Thursday 26 January 2017 23:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: NL
Contact:

Re: Python Plugin Beta testers - please read this

Post 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?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest