Python plugin: Kodi

Python and python framework

Moderator: leecollings

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 »

Too bad, the plugin crashed Domoticz again. Please, what can I do to prevent this?

Code: Select all

2018-09-27 10:51:26.023  Error: Plugin: Connection Exception: 'resolve: Host not found (authoritative)' connecting to 'onHeartbeat:9090'
2018-09-27 10:51:26.023  (Kodi Woonkamer) Connect directive received, action initiation failed.
2018-09-27 10:51:26.024  Error: Domoticz received fatal signal 11 !...
2018-09-27 10:51:26.027  Error:   /home/pi/domoticz/domoticz() [0x254670]
2018-09-27 10:51:26.027  Error:   /home/pi/domoticz/domoticz(_Z14signal_handleri+0x4c) [0x254728]
2018-09-27 10:51:26.027  Error:   /lib/arm-linux-gnueabihf/libc.so.6(__default_sa_restorer_v2+0) [0x76c35180]
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: Kodi

Post by Dnpwwo »

@jake,

Have you tried a more recent beta (along with the new version of the plugin from github)?

I'm not seeing any crashes with 2 Kodi's.
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 »

Dnpwwo wrote:@jake,

Have you tried a more recent beta (along with the new version of the plugin from github)?

I'm not seeing any crashes with 2 Kodi's.
I'm still running a beta from before the last stable. I am a bit hesitant to upgrade the OS from Jessie to Stretch, since some programs have (possibly had) issues with Stretch. I will need to make an image of the current SD-card content and just try, I guess.

In the mean time I did a 'git pull' of your plugin from 2.5.6 to 2.6.4. However, this resulted in errors in the log. Something about API. I guessed it had to do with my older beta release with also 'just' dzVents 2.4.6 instead of 2.4.7. I returned to 2.5.6 for the time being.

Anyhow, after 3 daily crashes out of the blue (no updates done to Kodi either) I decided to finally install Monit to prevent Domoticz staying offline for hours unnoticed. Ever since, Domoticz decided to behave and didn't crash anymore. Everything at peace now for 2d 20h according Monit.

Don't the mentioned error reports show a codig bug in your plugin? It seems to me that it wasn't able to handle an exception at some point. I'd rather see the Kodi plugin going offline than my whole Domoticz system, since Domoticz handles a lot of things in the house nowadays.
bkoch
Posts: 5
Joined: Tuesday 30 October 2018 12:22
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Kodi

Post by bkoch »

Hi,

I have installed a fresh Raspbian Stretchs Lite and Domoticz and the Kodi plugin. I had to install phyton3-dev to get the hardware visible. When it starts the log contains
2018-10-30 15:26:55.579 Status: PluginSystem: Started, Python version '3.5.3'.
The plugin does start up:
2018-10-30 15:26:58.517 Status: (Kodi woonkamer) Initialized version 2.6.4, author 'dnpwwo'

as soon as it connects to the RPi running kodi, I get an endless repetition of the next debug quote

2018-11-02 15:53:25.442 Error: (Kodi Player Woonkamer) 'onMessage' failed 'TypeError':'a bytes-like object is required, not 'str''.
2018-11-02 15:53:25.442 Error: (Kodi Player Woonkamer) ----> Line 641 in /home/pi/domoticz/plugins/Domoticz-Kodi-Plugin/plugin.py, function onMessage
2018-11-02 15:53:25.442 Error: (Kodi Player Woonkamer) ----> Line 148 in /home/pi/domoticz/plugins/Domoticz-Kodi-Plugin/plugin.py, function onMessage
2018-11-02 15:53:35.356 (Kodi Player Woonkamer) Pushing 'onHeartbeatCallback' on to queue
2018-11-02 15:53:35.359 (Kodi Player Woonkamer) Processing 'onHeartbeatCallback' message
2018-11-02 15:53:35.359 (Kodi Player Woonkamer) Calling message handler 'onHeartbeat'.
2018-11-02 15:53:35.359 (Kodi Player Woonkamer) Pushing 'WriteDirective' on to queue
2018-11-02 15:53:35.359 (Kodi Player Woonkamer) Processing 'WriteDirective' message
2018-11-02 15:53:35.359 (Kodi Player Woonkamer) Sending 62 bytes of data
2018-11-02 15:53:35.359 (Kodi Player Woonkamer) 7b 22 6a 73 6f 6e 72 70 63 22 3a 22 32 2e 30 22 2c 22 6d 65 {"jsonrpc":"2.0","me
2018-11-02 15:53:35.359 (Kodi Player Woonkamer) 74 68 6f 64 22 3a 22 50 6c 61 79 65 72 2e 47 65 74 41 63 74 thod":"Player.GetAct
2018-11-02 15:53:35.359 (Kodi Player Woonkamer) 69 76 65 50 6c 61 79 65 72 73 22 2c 22 69 64 22 3a 31 30 30 ivePlayers","id":100
2018-11-02 15:53:35.359 (Kodi Player Woonkamer) 31 7d .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 1}
2018-11-02 15:53:35.364 (Kodi Player Woonkamer) Pushing 'ReadEvent' on to queue
2018-11-02 15:53:35.409 (Kodi Player Woonkamer) Processing 'ReadEvent' message
2018-11-02 15:53:35.409 (Kodi Player Woonkamer) Received 39 bytes of data
2018-11-02 15:53:35.410 (Kodi Player Woonkamer) 7b 22 69 64 22 3a 31 30 30 31 2c 22 6a 73 6f 6e 72 70 63 22 {"id":1001,"jsonrpc"
2018-11-02 15:53:35.410 (Kodi Player Woonkamer) 3a 22 32 2e 30 22 2c 22 72 65 73 75 6c 74 22 3a 5b 5d 7d .. :"2.0","result":[]}
2018-11-02 15:53:35.410 (Kodi Player Woonkamer) Pushing 'onMessageCallback' on to queue
2018-11-02 15:53:35.410 (Kodi Player Woonkamer) Processing 'onMessageCallback' message
2018-11-02 15:53:35.410 (Kodi Player Woonkamer) Calling message handler 'onMessage'.

How can I solve this?
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: Kodi

Post by Dnpwwo »

@bkoch,

I'm guessing from the error that you have put an old version of Domoticz onto your new build.

You can either:
  • Up grade to a later version of Domoticz (recommended)
  • Down grade the plugin until you find the version that works with your version of Domoticz (2.5.6 should do 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
bkoch
Posts: 5
Joined: Tuesday 30 October 2018 12:22
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Kodi

Post by bkoch »

@Dnpwwo

I do have the latest stable version of Domoticz
2018-11-03 12:36:29.082 Status: Domoticz V4.9700 (c)2012-2018 GizMoCuz
2018-11-03 12:36:29.097 Status: Build Hash: a3a45906, Date: 2018-06-23 16:24:51

Do I have to use the beta version 4.10162?

In the mean time I will look for plugin version 2.5.6.
bkoch
Posts: 5
Joined: Tuesday 30 October 2018 12:22
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Kodi

Post by bkoch »

@Dnpwwo

I have installed plugin 2.5.6. The good news is that it is working. Thank you for your help.

The bad thing is that I don't know what caused it not to work. Can I expect a solution from Rasbian, Python or Domoticz?
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: Kodi

Post by Dnpwwo »

@bkoch,

The last two versions are functionally the same so there is no disadvantage to being on 2.5.6.

I checked the dates and you do need to be on the beta version of Domoticz to use the latest because it was committed late August.

My bad.
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
corederoma82
Posts: 85
Joined: Saturday 14 January 2017 21:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Kodi

Post by corederoma82 »

I receive this error, what it means?

I can use volume, I can switch between music/movies, but the status is always "off", so I can't use the remote controller....

018-11-25 19:10:58.004 (Kodi) Update 0:'' (Kodi - Playing)
2018-11-25 19:10:58.055 (Kodi) Connected successfully to: 192.168.1.23:9090
2018-11-25 19:10:58.105 Error: (Kodi) 'onMessage' failed 'TypeError':'Type str doesn't support the buffer API'.
2018-11-25 19:10:58.106 Error: (Kodi) ----> Line 641 in /home/pi/domoticz/plugins/Domoticz-Kodi-Plugin/plugin.py, function onMessage
2018-11-25 19:10:58.106 Error: (Kodi) ----> Line 148 in /home/pi/domoticz/plugins/Domoticz-Kodi-Plugin/plugin.py, function onMessage
2018-11-25 19:10:58.106 Error: (Kodi) 'onMessage' failed 'TypeError':'Type str doesn't support the buffer API'.
2018-11-25 19:10:58.106 Error: (Kodi) ----> Line 641 in /home/pi/domoticz/plugins/Domoticz-Kodi-Plugin/plugin.py, function onMessage
2018-11-25 19:10:58.106 Error: (Kodi) ----> Line 148 in /home/pi/domoticz/plugins/Domoticz-Kodi-Plugin/plugin.py, function onMessage
2018-11-25 19:10:58.106 Error: (Kodi) 'onMessage' failed 'TypeError':'Type str doesn't support the buffer API'.
2018-11-25 19:10:58.106 Error: (Kodi) ----> Line 641 in /home/pi/domoticz/plugins/Domoticz-Kodi-Plugin/plugin.py, function onMessage
2018-11-25 19:10:58.106 Error: (Kodi) ----> Line 148 in /home/pi/domoticz/plugins/Domoticz-Kodi-Plugin/plugin.py, function onMessage
2018-11-25 19:11:00.270 Status: EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_playstation_update.lua
2018-11-25 19:11:07.575 Error: (Kodi) 'onMessage' failed 'TypeError':'Type str doesn't support the buffer API'.
Raspberry PI 3, 3x Yeelight bulbs, 1x Yeeligh led strip, 1x Sonoff with ESP826, Controlicz, Kodi
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: Kodi

Post by Dnpwwo »

@corederoma82,

I'm going to need to know:
  • The Kodi version
  • The Domoticz version
  • The plugin version
before I can comment.
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
corederoma82
Posts: 85
Joined: Saturday 14 January 2017 21:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Kodi

Post by corederoma82 »

Dnpwwo wrote: Monday 26 November 2018 10:49 @corederoma82,

I'm going to need to know:
  • The Kodi version
  • The Domoticz version
  • The plugin version
before I can comment.
- Kodi is Krypton 17.6
- Domoticz 4.9700
- The plugin I think that is last version, I take it from here:
https://github.com/dnpwwo/Domoticz-Kodi-Plugin

Thanks
Raspberry PI 3, 3x Yeelight bulbs, 1x Yeeligh led strip, 1x Sonoff with ESP826, Controlicz, Kodi
kevin919
Posts: 1
Joined: Saturday 19 January 2019 12:53
Target OS: Linux
Domoticz version:
Contact:

Re: Python plugin: Kodi

Post by kevin919 »

thanks, this thread helped me :D
Labtec
Posts: 20
Joined: Friday 10 August 2018 19:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Kodi

Post by Labtec »

Hi,

Just installed the Kodi Player Plugin but I can't get it to work, what did I wrong?
Schermafbeelding 2019-02-01 om 14.39.06.png
Schermafbeelding 2019-02-01 om 14.39.06.png (247.57 KiB) Viewed 1953 times

Thanks
Labtec
Posts: 20
Joined: Friday 10 August 2018 19:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Kodi

Post by Labtec »

Some other logging

2019-02-01 14:45:11.132 (Kodi Media Player) Pushing 'onDisconnectCallback' on to queue
2019-02-01 14:45:11.132 (Kodi Media Player) Processing 'onDisconnectCallback' message
2019-02-01 14:45:11.132 (Kodi Media Player) Calling message handler 'onDisconnect'.
2019-02-01 14:45:11.132 (Kodi Media Player) Device has disconnected
2019-02-01 14:45:21.050 (Kodi Media Player) Pushing 'onHeartbeatCallback' on to queue
2019-02-01 14:45:21.100 (Kodi Media Player) Processing 'onHeartbeatCallback' message
2019-02-01 14:45:21.100 (Kodi Media Player) Calling message handler 'onHeartbeat'.
2019-02-01 14:45:31.054 (Kodi Media Player) Pushing 'onHeartbeatCallback' on to queue
2019-02-01 14:45:31.090 (Kodi Media Player) Processing 'onHeartbeatCallback' message
2019-02-01 14:45:31.091 (Kodi Media Player) Calling message handler 'onHeartbeat'.
2019-02-01 14:45:41.056 (Kodi Media Player) Pushing 'onHeartbeatCallback' on to queue
2019-02-01 14:45:41.097 (Kodi Media Player) Processing 'onHeartbeatCallback' message
2019-02-01 14:45:41.099 (Kodi Media Player) Calling message handler 'onHeartbeat'.
2019-02-01 14:45:41.099 (Kodi Media Player) Pushing 'ConnectDirective' on to queue
2019-02-01 14:45:41.099 (Kodi Media Player) Processing 'ConnectDirective' message
2019-02-01 14:45:41.099 (Kodi Media Player) Transport set to: 'TCP/IP', 192.168.1.22:9090.
2019-02-01 14:45:41.100 (Kodi Media Player) Connect directive received, action initiated successfully.
2019-02-01 14:45:41.101 (Kodi Media Player) Pushing 'onConnectCallback' on to queue
2019-02-01 14:45:41.103 (Kodi Media Player) Pushing 'DisconnectedEvent' on to queue
2019-02-01 14:45:41.150 (Kodi Media Player) Processing 'onConnectCallback' message
2019-02-01 14:45:41.150 (Kodi Media Player) Calling message handler 'onConnect'.
2019-02-01 14:45:41.150 (Kodi Media Player) Failed to connect (111) to: 192.168.1.22:9090
2019-02-01 14:45:41.150 (Kodi Media Player) Failed to connect (111) to: 192.168.1.22:9090 with error: Connection refused
2019-02-01 14:45:41.151 (Kodi Media Player) Processing 'DisconnectedEvent' message
2019-02-01 14:45:41.151 (Kodi Media Player) Disconnect event received for '192.168.1.22:9090'.
2019-02-01 14:45:41.151 (Kodi Media Player) Pushing 'onDisconnectCallback' on to queue
2019-02-01 14:45:41.151 (Kodi Media Player) Processing 'onDisconnectCallback' message
2019-02-01 14:45:41.151 (Kodi Media Player) Calling message handler 'onDisconnect'.
2019-02-01 14:45:41.151 (Kodi Media Player) Device has disconnected
2019-02-01 14:45:51.057 (Kodi Media Player) Pushing 'onHeartbeatCallback' on to queue
2019-02-01 14:45:51.097 (Kodi Media Player) Processing 'onHeartbeatCallback' message
Labtec
Posts: 20
Joined: Friday 10 August 2018 19:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Kodi

Post by Labtec »

Problem solved, wrong port setting and setting in Kodi player "allow access......."
madhusree
Posts: 2
Joined: Tuesday 05 February 2019 7:18
Target OS: -
Domoticz version:
Location: India
Contact:

Re: Python plugin: Kodi

Post by madhusree »

I need to to thank you for this fantastic read!!
Loky31
Posts: 40
Joined: Monday 11 March 2019 13:46
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Kodi

Post by Loky31 »

Hello,

just a simple question :)

When it comes to the "Trigger Playlist <name>" command, is the correct typo 'Trigger Playlist cine' , with the cine.m3u playlist added to the Kodi ?

I've tried it and got an error saying that the playlist does not exist:
2019-05-27 08:14:39.084 Error: (kodi salon) Playlist 'cine.m3u' could not be added, probably does not exist.
2019-05-27 08:14:39.159 Error: Error executing script command (/home/pi/domoticz/scripts/Multimedia-musique cinema test). returned: 32512

Is there a particular way to create the playlist or whatever?
Or my command is not good somehow?
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 »

When audio is played, the screensaver becomes active after 5 minutes. This is fine, since the connected screen is off during audio play anyway. However within Domoticz my script goes haywire, since the screensaver status is in this case not the indication that Kodi is idling (reason to shut down my receiver).
To make it worse, the next played song will put the Kodi - Status device back to 'Audio' and keeps doing so until it reaches the end of the album and displays 'On' instead. For me I don't know when the user is active in the GUI or not, making it impossible for me to decide when to shutdown the receiver.

With help of dzVents I am able to bypass the described problem in a script.

I think it is a flaw in the current plugin that wen the GUI status update goes to "sleeping", or "screensaver" (don't know how it is called from Kodi) to conclude that everything is stopped. Of course this is true for Video, but not for Audio. Therefore the Kodi - Status device should keep it's status of 'Audio' in that case + Kodi - Playing should continue it's percentage and not go to 'Off'

I now check during a status change to 'Sleeping' this:
{"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params":{"booleans":["Player.HasAudio"]},"id":1}
If yes, I try to update the Kodi - Status device to 'Audio (5), although I am not very successful doing so (I can't do it 'silent', so the correction triggers my script again) and I can't update the playing song, since I don't know how to pass this on to the device.

This is my code that after trying a lot of different 'update device status' methods didn't succeed:

Code: Select all

kodi_status.update(5).silent()
State 0 = Off, 1 = On, 4 = Video 5 = Audio and 9 = Sleeping.

Questions:
1: How can I update the Kodi status device silently with dzVents
2: How can I update the 'song text' within the status device

Too bad the originator of the plugin doesn't seem te be around anymore, so fixing at the source is impossible for me. I studied his code on Github, but I can't make much sense from it. https://github.com/dnpwwo/Domoticz-Kodi ... /plugin.py
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: Kodi

Post by Dnpwwo »

@jake,

There are a number of ways to resolve this, but the cleanest is always to fix things at the source given that the plugin's job is to reflect what the Kodi is doing. I'm going to assume you are running Kodi v17 given that this has not been reported before.

Previous Kodi versions showed visualisations when you played audio and these prevented the screensaver from kicking in, in v17 these have been removed by default which is probably causing this (I'm on a very old version for advert skipping capabilities so don't know for sure).

Can you try adding a visualisation back in? This link shows how: https://www.youtube.com/watch?v=08AsPbUJkZk
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 »

@Dnpwwo Good to hear from you! I am on Kodi 18.7 or 18.8, at the least the most recent stable. Yes, I'd rather fix it at the source (meaning, updating the plugin). I am not a fan of visualisation while playing audio, since it is CPU intensive, generating heat.

I am not capable to work with the python programming language and therefore I find the plugin code a little abstract. What I do understand of it is that when Kodi publishes that the screensaver kicked in, it is received in the plugin as the start of a sleep period, even stopping the domoticz 'kodi - playing' device. In the recent version of Kodi this is not true for Audio.

My suggestion for plugin improvement:
At reception of status 'Screensaver'
Check if media is still playing.
If no, continue as is todoay
if yes, check whether it is still video or audio and further ignore the status update (in other words, dont update the domoticz device)

(since the devices 'status' and 'playing' are updated as usuals when the next audio song starts, my suggestion would make the devices work again as they are supposed to)

At the reception of status 'On' (since, with the problem for Audio as described here above, at the end of a played album the status changes to 'On' and never again to 'screensaver' unless a Kodi interface button is pressed and the screensaver will be activated 5 minutes later)
Check whether the screensaver is on
If no, leave the status on
If yes, change the status to 'Screensaver'

When a video is started from Youtube (at least), the domoticz log shows 2 status updates: Kodi status (9), followed by (4). This happens in a split second, but the state (9) (=sleeping) already triggers the wrong part of my script.
Suggestion of improvement:
When the status is updated (9) wait for 0,5 sec before publishing?
Domoticz log at every video (from Youtbe) start

Code: Select all

2020-09-06 09:52:38.053  (Kodi Woonkamer) GUI.OnScreensaverDeactivated received, Player ID: -1
2020-09-06 09:52:38.087  (Kodi Woonkamer) Update 1:'' (Kodi Woonkamer - Status)
2020-09-06 09:52:40.167  (Kodi Woonkamer) Update 9:'' (Kodi Woonkamer - Status)
2020-09-06 09:52:40.250  (Kodi Woonkamer) Update 4:' xyz selected video' (Kodi Woonkamer - Status)
2020-09-06 09:52:40.281  (Kodi Woonkamer) Update 2:'0' (Kodi Woonkamer - Playing)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest