A small Go daemon that reads notifications from Kodi/XBMC via the JSON-RPC socket, and performs actions based on those notifications.
I wrote this primarily because the Python callback interface can get blocked very easily by any add-on, which results in heavy delays getting callbacks executed (for example, using the service.xbmc.callbacks plugin), whereas notifications are shipped over the JSON interface immediately.
This is not an issue with service.xbmc.callbacks
(good work pilluli
!), but with the Kodi add-on infrastructure, and with other individual add-ons.
This daemon also aims to provide more flexibility. The targeted backends are hyperion, kodi
, lifx
and shell
.
Due to the name change to keep in line with XBMC's new name Kodi, if you have the previous package installed as xbmc-callback-daemon
, you should uninstall it before installing the new kodi-callback-daemon
. The init scripts should handle your existing /etc/xbmc-callback-daemon.json
config file, but you're encouraged to move this to the new location /etc/kodi-callback-daemon.json
as this feature may go away in future to avoid confusion.
The Hyperion backend submits callbacks via the JSON interface. This interface is also used by the hyperion-remote
command-line utility. There's no end-user documentation for this interface, so when writing callbacks, your best bet is to simply read the JSON schemas in the source tree.
The Kodi backend submits callbacks via the JSON-RPC interface. There is excellent documentation available in the Kodi wiki.
The LIFX backend submits callbacks via the LIFX LAN protocol. Callbacks are written in a local format, detailed below
The shell backend simply executes a command on the system with specified arguments.
Grab the Latest Release as a compiled binary and either install it using your package manager (Debian/Ubuntu/derivs, via the .deb
package), or extract kodi-callback-daemon
to somewhere on your path (eg - /usr/local/bin
) on Linux/OSX/FreeBSD, or where ever on Windows.
Alternatively, you may clone this repository and build it yourself.
NB: I've not actually tested Windows/OSX/FreeBSD support at all, feel free to submit bug reports
You must configure Kodi to accept remote control request, by enabling the options:
Allow programs on this system to control Kodi
Allow programs on other systems to control Kodi
In Kodi settings at System Settings
-> Network
-> Remote Control
Linux/OSX/FreeBSD:
/path/to/bin/kodi-callback-daemon /path/to/configFile.json
Windows:
C:\Path\To\kodi-callback-daemon.exe C:\Path\To\configFile.json
The deb packages include SysV and Upstart init scripts and a systemd unit - enable and use them in the standard fashion. You will need to add your configuration file at:
/etc/kodi-callback-daemon.json
Alternatively, you may edit /etc/default/kodi-callback-daemon
and set the path to your configuration file there.
You can find the SysV init script at kodi-callback-daemon.init, and the systemd unit at kodi-callback-daemon.service. Place the SysV script in /etc/init.d/
, or the systemd unit at /etc/systemd/system/
, and enable/start the service as you normally would.
You might alternatively start the daemon from Kodi's autostart.py
. Simply edit userdata/autoexec.py
in your Kodi directory (ie ~/.kodi/userdata/autoexec.py
on *nix systems), and add the following:
Linux/OSX/FreeBSD:
import kodi
import subprocess
subprocess.Popen(['/path/to/bin/kodi-callback-daemon', '/path/to/configFile.json'])
Windows:
import kodi
import subprocess
subprocess.Popen(['C:\\Path\\To\\kodi-callback-daemon.exe', 'C:\\Path\\To\\configFile.json'])
Note the double-slashes necessary for escaping the Windows paths in Python strings.
Note: If you're using this method, you'll also want to make sure that the daemon is killed on Kodi exit or startup, otherwise you'll get multiple copies running and they'll fight for resources. I'm not a Python guy, so I'm open to suggestions on how to best handle this.
If you have questions on how to use the daemon, you may post them in the Kodi forum thread.
The configuration file is written in JSON (I know, JSON is awful for configuration, but since we're passing JSON messages everywhere, it makes the most sense here), and has the following top-level members:
kodi
object defines the Kodi connection parameters (required)hyperion
object defines the hyperion connection parameters (optional, but required if you're using the Hyperion backend)lifx
object defines the lifx connection parameters (optional, but required if you're using the LIFX backend)debug
boolean enables debug logging (optional)callbacks
object (required, or nothing will be done!).
See the config.example.json for my Hyperion/LIFX setup, which uses most of the available features.
Specify your Kodi/XBMC IP address and port for the JSON interface in the kodi
property:
{
"kodi": {
"address": "127.0.0.1",
"port": 9090
}
}
If you're using the Hyperion backend, specify your Hyperion address and port for the JSON interface in the hyperion
property:
{
"kodi": {
"address": "127.0.0.1",
"port": 9090
},
"hyperion": {
"address": "127.0.0.1",
"port": 19444
}
}
If you're using the LIFX backend, you just need to declare it as an object.
{
"kodi": {
"address": "127.0.0.1",
"port": 9090
},
"lifx": {}
}