DeutscheMark/homebridge-kodi

Plugin with Kodi off slows down Homebridge

ericu65 opened this issue ยท 7 comments

Describe The Bug:
Using latest Homebridge 1.3.1 will log problematic plugins in terms of unresponsive characteristics. homebridge-kodi at version 1.0.1 will log warnings regarding its responsiveness when Kodi is not running.

To Reproduce:
Without kodi running restart Homebridge running v1.3.1. It will show: [homebridge-kodi] This plugin slows down Homebridge

Expected behavior:
When Kodi is not running the states should still be reported as in https://github.com/homebridge/homebridge/wiki/Characteristic-Warnings#this-plugin-slows-down-homebridge

Logs:

[2/24/2021, 18:56:28] Homebridge v1.3.1 (HomebridgeTV) is running on port XXXXX.
[2/24/2021, 18:56:30] [CMD Switch] Kodi Start is on.
[2/24/2021, 18:56:33] [homebridge-kodi] This plugin slows down Homebridge. The read handler for the characteristic 'On' was slow to respond! See https://git.io/JtMGR for more info.
[2/24/2021, 18:56:33] [homebridge-kodi] This plugin slows down Homebridge. The read handler for the characteristic 'On' was slow to respond! See https://git.io/JtMGR for more info.
[2/24/2021, 18:56:33] [homebridge-kodi] This plugin slows down Homebridge. The read handler for the characteristic 'Brightness' was slow to respond! See https://git.io/JtMGR for more info.
[2/24/2021, 18:56:36] [CMD Switch] Kodi Start is on.
[2/24/2021, 18:56:39] [homebridge-kodi] This plugin slows down Homebridge. The read handler for the characteristic 'On' was slow to respond! See https://git.io/JtMGR for more info.
[2/24/2021, 18:56:39] [homebridge-kodi] This plugin slows down Homebridge. The read handler for the characteristic 'On' was slow to respond! See https://git.io/JtMGR for more info.
[2/24/2021, 18:56:39] [homebridge-kodi] This plugin slows down Homebridge. The read handler for the characteristic 'Brightness' was slow to respond! See https://git.io/JtMGR for more info.
[2/24/2021, 18:56:39] [Homebridge UI] Homebridge Config UI X v4.39.0 is listening on :: port XXXX
[2/24/2021, 18:56:39] [homebridge-kodi] This plugin slows down Homebridge. The read handler for the characteristic 'On' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info.
[2/24/2021, 18:56:39] [homebridge-kodi] This plugin slows down Homebridge. The read handler for the characteristic 'On' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info.
[2/24/2021, 18:56:39] [homebridge-kodi] This plugin slows down Homebridge. The read handler for the characteristic 'Brightness' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info.
[2/24/2021, 18:56:45] [homebridge-kodi] This plugin slows down Homebridge. The read handler for the characteristic 'On' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info.
[2/24/2021, 18:56:45] [homebridge-kodi] This plugin slows down Homebridge. The read handler for the characteristic 'On' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info.
[2/24/2021, 18:56:45] [homebridge-kodi] This plugin slows down Homebridge. The read handler for the characteristic 'Brightness' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info..

Environment:

  • Plugin Version: 1.0.1
  • Homebridge Version: 1.3.1
  • Node.js Version: 12.20.1
  • NPM Version: 7.5.6
  • Operating System: Raspbian

Hi,

I'm already working on v1.1.0 where a new power button is introduced and all buttons won't show warnings/errors anymore when Kodi is not running to support this feature so all of those warnings/errors should disappear. In general it will be better usable with Homebridge 1.3.x. :)

But thanks for pointing that out. :)
DM

Hi DM,
The issue template was a little rigid and didn't provide a section for praise so the comment is a better place for it. Before your homebridge-kodi I had created a barebones HB plugin to pause/play Kodi but progress was really slow (C++ dev here, no JS experience). Your plugin solved everything I needed and I use it all the time! Thanks.

I guess the only issues I have are the often remote (iOS remote) not appearing anylonger and the slowdown of HB when Kodi is not running.

In my case Kodi runs on the desktop PC since that's connected to my Amp and Projector so it's only running when watching something and HB is on a RPi. I guess the design of homebridge-kodi was initially that Kodi was already running on RPi so not a huge issue because it's always available to respond with state.

I have a task in HB running from cmdSwitch2 plugin to set external monitor to on and open Kodi via SSH: ssh <ip> schtasks /Run /TN StartKodi which runs a task on Windows with the folowing tasks:

displayswitch.exe /external
timeout 10
powershell -command &{$wshShell = new-object -com wscript.shell; for ($num = 1 ; $num -le 50 ; $num++){$wshShell.SendKeys([char]175)}} //brutally sets volume to 100%
cmd /c "C:\Program Files\Kodi\kodi.exe"

Task scheduler was already available in Windows and can run GUI apps as opposed to running directly in SSH. There is another sysinternals tool that can run them with GUI but this was already available in Windows this way.

Then for this task I get the state (so I can run it again without toggling OFF - ON) by the command curl -s -I -m 1 http://<ip:port>/jsonrpc. This can be an easy solution for your plugin so you can quickly get the state without trying all the other accessories. Maybe just poll this every interval (30s) and if return code is not 0 save this internally and when HB requests state instantly provide state as OFF. At least this is what I can come up with which can solve this.

Thank you,
Eric

A second note:

[2/26/2021, 13:10:21] [Kodi] Kodi Notifications: Kodi does not seem to be running - Retry in 30 seconds
Seems the plugin internally uses this check to see if Kodi is running and checking every retrytime interval. So why is the plugin not responding if it knows that Kodi is not running? The simplest solution now would be to instantly respond OFF (or default/idle state) for all accessories when this retrytime interval is running.

Hi Eric,

the log you're seeing is used for subscribing to notifications that Kodi sends on status changes, e.g. "onPlay" or something like that. This subscription is needed to change the status of the accessories so it checks if Kodi is running to be aware when it is possible to subscribe to those notifications.

With v1.1.0 I will optimize all of that and add another method to check if Kodi is running.
The plugin will then not throw warnings/errors anymore.
All accessories will take the new power on/off feature into account and are simply off in that case.

Thank you,
DM

Hi Eric,

you can beta test the new v1.1.0 that improves the problem right now with "npm install -g homebridge-kodi@beta".

Please let me know if you experience any problems.

Thank you
DM

Hi @DeutscheMark

Thank you for the heads up. I have meanwhile migrated to Apple TV (not least because of the integration I have with it) so I am no longer able to test. I may as well close this ticket.

Much appreciated,
Eric

@DeutscheMark is there any update on this one? Or a release date for 1.1.0?