Python plugin: Kodi

Python and python framework

Moderator: leecollings

User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: Python plugin: Kodi

Post by G3rard »

capman wrote:Domoticz version beta 3.7468 with python from Jadahl on synology. Plugin version 1.7.1
Get some errors in the log
The plugin 1.7.1 is for the latest Domoticz beta versions, you have an older version (I actually have the same version).
So you need the 1.6.0 version of the plugin.
Not using Domoticz anymore
User avatar
capman
Posts: 153
Joined: Friday 12 July 2013 20:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Belgium
Contact:

Re: Python plugin: Kodi

Post by capman »

G3rard wrote:
capman wrote:Domoticz version beta 3.7468 with python from Jadahl on synology. Plugin version 1.7.1
Get some errors in the log
The plugin 1.7.1 is for the latest Domoticz beta versions, you have an older version (I actually have the same version).
So you need the 1.6.0 version of the plugin.
Rollback 2 version 1.6.0. It's working now. I don't won't to update my previous version of domoticz because there are some issues with
the plugins. So a wait until ... :D

Thanks 4 helping :)
Luuc_a
Posts: 24
Joined: Tuesday 16 July 2013 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Python plugin: Kodi

Post by Luuc_a »

With the latest beta (3.7686) the Kodi plugin doesn't work anymore.
Version 1.7.1 will crash domoticz and version 1.6.0 result in the folowing error

OnStart:

Code: Select all

2017-06-08 07:57:11.198 Error: (Kodi Woonkamer) 'onStart' failed 'AttributeError':''module' object has no attribute 'Transport''. 
 2017-06-08 07:57:11.198 Error: (Kodi Woonkamer) ----> Line 528 in /home/pi/domoticz/plugins/Kodi/plugin.py, function onStart 
 2017-06-08 07:57:11.198 Error: (Kodi Woonkamer) ----> Line 96 in /home/pi/domoticz/plugins/Kodi/plugin.py, function onStart
OnHeartbeat:

Code: Select all

2017-06-08 07:57:40.746 Error: (Kodi Woonkamer) 'onHeartbeat' failed 'AttributeError':''module' object has no attribute 'Connect''. 
 2017-06-08 07:57:40.746 Error: (Kodi Woonkamer) ----> Line 556 in /home/pi/domoticz/plugins/Kodi/plugin.py, function onHeartbeat 
 2017-06-08 07:57:40.746 Error: (Kodi Woonkamer) ----> Line 446 in /home/pi/domoticz/plugins/Kodi/plugin.py, function onHeartbeat
Is there a solution for this?
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python plugin: Kodi

Post by Dnpwwo »

@Luuc_a,

I'm not sure.

It would be more useful if you posted the log for version 1.7.1 (preferably with debug enabled for the plugin) rather than the version that we know doesn't work with the new beta, also the operating system you are running.
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
Luuc_a
Posts: 24
Joined: Tuesday 16 July 2013 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Python plugin: Kodi

Post by Luuc_a »

Dnpwwo wrote:@Luuc_a,

I'm not sure.

It would be more useful if you posted the log for version 1.7.1 (preferably with debug enabled for the plugin) rather than the version that we know doesn't work with the new beta, also the operating system you are running.
Well. That would be a problem. I don't have the log for version 1.7.1 because domoticz is not reachable with this version.
The web interface says that it is offline. Is there another method to get the log?

I use Domoticz on a raspberry pi3.
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python plugin: Kodi

Post by Dnpwwo »

@Luuc_a,

Yes. If you go onto the Pi into the domoticz directory you can run it using somthing like

Code: Select all

./domoticz
then you will see the output
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
Luuc_a
Posts: 24
Joined: Tuesday 16 July 2013 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Python plugin: Kodi

Post by Luuc_a »

Thanks. I get different errors when I try this. But also found the solution.
It was a permission error.

The solution

Code: Select all

sudo chmod 755 domotiz/plugins/kodi/plugin.py
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Python plugin: Kodi

Post by jake »

jake wrote:@Dnpwwo, do you think you will be able to complete the feature request to add another Kodi state (besides on/off/video/audio): something like sleep, by detecting when the screensaver is active?
@Dnpwwo: I did some research if my original request to get a Kodi 'idle' or 'sleep' state in Domotizc. Would it be possible to integrate the OnScreenSaverActivated functionality in your plugin? In this forum someone tries to use OnScreenSaverActivated, but gets into trouble because Kodi dims the screen while playing audio: https://www.google.nl/url?sa=t&source=w ... l2r-jEMtAQ

UPDATE: I found the plugin for Kodi "Kodi Callbacks" and their I could use an http command to enable/disable a new virtual switch in Domoticz at the Kodi state of 'OnIdle' and 'onResumeAfterIdle'
However, the 'idle' state in Domoticz directly, would be preferred, of course ;-)
User avatar
Brutus
Posts: 249
Joined: Friday 26 September 2014 9:33
Target OS: Windows
Domoticz version:
Location: Netherlands
Contact:

Re: Python plugin: Kodi

Post by Brutus »

After upgrading to Domoticz version V3.8235 on Windows i'm getting these errors using plugin version 1.7.1:

Code: Select all

2017-08-06 23:53:51.387 Error: (Kodi Woonkamer) 'onMessage' failed 'TypeError':'onMessage() missing 2 required positional arguments: 'Status' and 'Extra''. 

Code: Select all

2017-08-06 23:55:41.394 Error: (Kodi Woonkamer) 'onHeartbeat' failed 'AttributeError':'module 'Domoticz' has no attribute 'Disconnect''. 

 2017-08-06 23:55:41.394 Error: (Kodi Woonkamer) ----> Line 546 in C:\Program Files (x86)\Domoticz\plugins\Kodi\plugin.py, function onHeartbeat 

 2017-08-06 23:55:41.394 Error: (Kodi Woonkamer) ----> Line 423 in C:\Program Files (x86)\Domoticz\plugins\Kodi\plugin.py, function onHeartbeat 
1x Intel NUC8i5BEK (Windows 10 x64) Domoticz on Virtualbox with DietPi.
1x Aeon Labs USB Z-Stick S2
1x P1 Smart Meter USB
28x Fibaro Modules
SMA Solar System
Daikin Airco / Heating
Denon DHT-S716H & DSW-1H
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python plugin: Kodi

Post by Dnpwwo »

@Brutus,

There was a breaking change to the Python Framework at the start of the month.

Good news for you is that there is a a Kodi v1.8.0 plugin in the 'examples' folder that should work with the new API.

Let me know if it doesn't.
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
User avatar
Brutus
Posts: 249
Joined: Friday 26 September 2014 9:33
Target OS: Windows
Domoticz version:
Location: Netherlands
Contact:

Re: Python plugin: Kodi

Post by Brutus »

Dnpwwo wrote:@Brutus,

There was a breaking change to the Python Framework at the start of the month.

Good news for you is that there is a a Kodi v1.8.0 plugin in the 'examples' folder that should work with the new API.

Let me know if it doesn't.
And were can I find this "Examples" Folder? The only folder I can find is in the dzvents folder.
1x Intel NUC8i5BEK (Windows 10 x64) Domoticz on Virtualbox with DietPi.
1x Aeon Labs USB Z-Stick S2
1x P1 Smart Meter USB
28x Fibaro Modules
SMA Solar System
Daikin Airco / Heating
Denon DHT-S716H & DSW-1H
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python plugin: Kodi

Post by Dnpwwo »

@Brutus,

domoticz/plugins/examples or https://github.com/domoticz/domoticz/tr ... s/examples
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
User avatar
Brutus
Posts: 249
Joined: Friday 26 September 2014 9:33
Target OS: Windows
Domoticz version:
Location: Netherlands
Contact:

Re: Python plugin: Kodi

Post by Brutus »

Dnpwwo wrote:@Brutus,

domoticz/plugins/examples or https://github.com/domoticz/domoticz/tr ... s/examples
Thank you that folder did not exist on my Windows Installation.
1x Intel NUC8i5BEK (Windows 10 x64) Domoticz on Virtualbox with DietPi.
1x Aeon Labs USB Z-Stick S2
1x P1 Smart Meter USB
28x Fibaro Modules
SMA Solar System
Daikin Airco / Heating
Denon DHT-S716H & DSW-1H
User avatar
Brutus
Posts: 249
Joined: Friday 26 September 2014 9:33
Target OS: Windows
Domoticz version:
Location: Netherlands
Contact:

Re: Python plugin: Kodi

Post by Brutus »

@Dnpwwo,

Maybe its me but in the examples folder there is one file named: Kodi.py

The "Old" Kodi plugin 1.7.1 has multiple files but no Kodi.py

So I can't replace it. How to update to version 1.8.0?
1x Intel NUC8i5BEK (Windows 10 x64) Domoticz on Virtualbox with DietPi.
1x Aeon Labs USB Z-Stick S2
1x P1 Smart Meter USB
28x Fibaro Modules
SMA Solar System
Daikin Airco / Heating
Denon DHT-S716H & DSW-1H
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python plugin: Kodi

Post by Dnpwwo »

@Brutus,

Just rename it plugin.py and drop it in your existing Kodi folder. In the Domoticz Hardware page select your Kodi and hit update to reload 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
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Python plugin: Kodi

Post by jake »

jake wrote:
jake wrote:@Dnpwwo, do you think you will be able to complete the feature request to add another Kodi state (besides on/off/video/audio): something like sleep, by detecting when the screensaver is active?
@Dnpwwo: I did some research if my original request to get a Kodi 'idle' or 'sleep' state in Domotizc. Would it be possible to integrate the OnScreenSaverActivated functionality in your plugin? In this forum someone tries to use OnScreenSaverActivated, but gets into trouble because Kodi dims the screen while playing audio: https://www.google.nl/url?sa=t&source=w ... l2r-jEMtAQ

UPDATE: I found the plugin for Kodi "Kodi Callbacks" and their I could use an http command to enable/disable a new virtual switch in Domoticz at the Kodi state of 'OnIdle' and 'onResumeAfterIdle'
However, the 'idle' state in Domoticz directly, would be preferred, of course ;-)
I figured it out how to get the http://kodi.wiki/view/Add-on:Kodi_Callbacks working within Kodi:
-Install the add-on via de built in add-on manager in Kodi
-In the configuration of the add-on
-- create a task: http, url = domoticz url:8080/json.htm and as type: GET
-- create an event on the activity 'OnIdle' with 'Task 1' and the custom text the JSON command parameters as described in the https://www.domoticz.com/wiki/Domoticz_ ... JSON wiki, starting with the ?type=command&param=switchlight&idx=99&switchcmd=On (idx=99: change to your virtual switch idx that is used to define if Kodi is idle)
--repeat the event 2 but choosing the on ResumeAfterIdle instead and the same task 1

The event delay in seconds starts counting from the first second that Kodi is Idle, not as I expected 'after the screensaver kicks in, but right then when audio or video stops and no UI is used

@Dnpwwo:
I realize that I use the onIdle from within Kodi and use the time delay also from within that add-on. From just the Domoticz side it might be more difficult to create a timer within Domoticz, the idle time variable should be defined in the 'hardware' section of Domoticz, I guess.

Another practical approach could be: combine the OnScreenSaverActivated information with the current 'On' state in the Domoticz plugin. I assume that would also give a reliable 'idle' state, since 'On' is only displayed when no audio/video is playing. The screensaver also only kicks in when there is no UI interaction.





Last edited by jake on Monday 07 August 2017 19:16, edited 6 times in total.
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python plugin: Kodi

Post by zak45 »

Hi,
have installed Kodi 1.8.0, got this error every 10 seconds:

2017-08-23 17:24:16.857 (kodi) Initialized version 1.8.0, author 'dnpwwo'
2017-08-23 17:24:16.858 PluginSystem: Starting I/O service thread.
2017-08-23 17:24:16.909 (kodi) Connected successfully to: 192.168.1.12:9090
2017-08-23 17:24:16.959 Error: (kodi) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2017-08-23 17:24:16.959 Error: (kodi) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2017-08-23 17:24:16.960 Error: (kodi) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2017-08-23 17:24:20.326 (RFX433E) Temp + Humidity (433-TempSalon)
2017-08-23 17:24:26.373 (AeonStick) Lux (Z-Lux Dressing)
2017-08-23 17:24:26.427 Error: (kodi) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2017-08-23 17:24:26.512 (AeonStick) Temp (Z-Temperature Dressing)
2017-08-23 17:24:30.619 (RFX433E) Temp + Humidity (433-TempExt)
2017-08-23 17:24:36.442 Error: (kodi) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2017-08-23 17:24:43.098 (RM2 Salon) Calling message handler 'onHeartbeat'.
2017-08-23 17:24:46.454 Error: (kodi) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2017-08-23 17:24:48.668 (RFX433E) Energy (Compteur EDF)
2017-08-23 17:24:48.920 (RFX433E) Temp + Humidity (433-TempSDBE)
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python plugin: Kodi

Post by zak45 »

Have put Debug on, should help....

2017-08-24 23:20:26.311 (kodi) 7b 22 6a 73 6f 6e 72 70 63 22 3a 22 32 2e 30 22 2c 22 6d 65 {"jsonrpc":"2.0","me
2017-08-24 23:20:26.312 (kodi) 74 68 6f 64 22 3a 22 50 6c 61 79 65 72 2e 47 65 74 41 63 74 thod":"Player.GetAct
2017-08-24 23:20:26.312 (kodi) 69 76 65 50 6c 61 79 65 72 73 22 2c 22 69 64 22 3a 31 30 30 ivePlayers","id":100
2017-08-24 23:20:26.312 (kodi) 31 7d .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 1}
2017-08-24 23:20:26.362 (kodi) Received 39 bytes of data:.
2017-08-24 23:20:26.362 (kodi) 7b 22 69 64 22 3a 31 30 30 31 2c 22 6a 73 6f 6e 72 70 63 22 {"id":1001,"jsonrpc"
2017-08-24 23:20:26.362 (kodi) 3a 22 32 2e 30 22 2c 22 72 65 73 75 6c 74 22 3a 5b 5d 7d .. :"2.0","result":[]}
2017-08-24 23:20:26.363 (kodi) Calling message handler 'onMessage'.
2017-08-24 23:20:26.363 Error: (kodi) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2017-08-24 23:20:27.869 (RFX433E) Temp + Humidity (433-TempExt)
2017-08-24 23:20:29.372 (Orange) Calling message handler 'onHeartbeat'.
2017-08-24 23:20:33.378 (RM2 Salon) Calling message handler 'onHeartbeat'.
2017-08-24 23:20:36.335 (kodi) Calling message handler 'onHeartbeat'.
2017-08-24 23:20:36.335 (kodi) Sending 62 bytes of data:.
2017-08-24 23:20:36.335 (kodi) 7b 22 6a 73 6f 6e 72 70 63 22 3a 22 32 2e 30 22 2c 22 6d 65 {"jsonrpc":"2.0","me
2017-08-24 23:20:36.336 (kodi) 74 68 6f 64 22 3a 22 50 6c 61 79 65 72 2e 47 65 74 41 63 74 thod":"Player.GetAct
2017-08-24 23:20:36.336 (kodi) 69 76 65 50 6c 61 79 65 72 73 22 2c 22 69 64 22 3a 31 30 30 ivePlayers","id":100
2017-08-24 23:20:36.336 (kodi) 31 7d .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 1}
2017-08-24 23:20:36.387 (kodi) Received 39 bytes of data:.
2017-08-24 23:20:36.387 (kodi) 7b 22 69 64 22 3a 31 30 30 31 2c 22 6a 73 6f 6e 72 70 63 22 {"id":1001,"jsonrpc"
2017-08-24 23:20:36.387 (kodi) 3a 22 32 2e 30 22 2c 22 72 65 73 75 6c 74 22 3a 5b 5d 7d .. :"2.0","result":[]}
2017-08-24 23:20:36.387 (kodi) Calling message handler 'onMessage'.
2017-08-24 23:20:36.387 Error: (kodi) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2017-08-24 23:20:44.338 (RFX433E) Temp + Humidity (433-TempSDBE)
2017-08-24 23:20:46.355 (kodi) Calling message handler 'onHeartbeat'.
2017-08-24 23:20:46.355 (kodi) Sending 62 bytes of data:.
2017-08-24 23:20:46.355 (kodi) 7b 22 6a 73 6f 6e 72 70 63 22 3a 22 32 2e 30 22 2c 22 6d 65 {"jsonrpc":"2.0","me
2017-08-24 23:20:46.356 (kodi) 74 68 6f 64 22 3a 22 50 6c 61 79 65 72 2e 47 65 74 41 63 74 thod":"Player.GetAct
2017-08-24 23:20:46.356 (kodi) 69 76 65 50 6c 61 79 65 72 73 22 2c 22 69 64 22 3a 31 30 30 ivePlayers","id":100
2017-08-24 23:20:46.356 (kodi) 31 7d .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 1}
2017-08-24 23:20:46.406 (kodi) Received 39 bytes of data:.
2017-08-24 23:20:46.406 (kodi) 7b 22 69 64 22 3a 31 30 30 31 2c 22 6a 73 6f 6e 72 70 63 22 {"id":1001,"jsonrpc"
2017-08-24 23:20:46.406 (kodi) 3a 22 32 2e 30 22 2c 22 72 65 73 75 6c 74 22 3a 5b 5d 7d .. :"2.0","result":[]}
2017-08-24 23:20:46.407 (kodi) Calling message handler 'onMessage'.
2017-08-24 23:20:46.407 Error: (kodi) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python plugin: Kodi

Post by Dnpwwo »

@zak45,

There was a plugin API change a few weeks ago and you appear to be attempting to run the new Kodi API against the previous Domoticz version (hence the parameter mismatch).

You need to upgrade Domoticz (if you are running the beta) or downgrade the Kodi plugin.
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
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python plugin: Kodi

Post by zak45 »

thanks lot @Dnpwwo

just to summarize: need Kodi v 1.7.1 with last stable Domoticz v 3.8153
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest