This is a SmartApp which allows you to control Kodi, where HTTP control has been enabled.
Controlling Kodi through SmartThings has the additional benefit that you are also be to trigger events in SmartThings based on events in Kodi, or visa versa. Such as ‘Someone is at the door, pause playback’, or ‘Kodi is playing, dim the living room lights’.
Install the ‘Kodi Manager’ SmartApp from your mobile device, specify your Kodi IP and Kodi login details.
This will then create a device for that kodi device.
In order to accomplish this the app exposes URL endpoints including a security token for each event type and provides them to the user in a easy to copy/paste format (no more messing with REST endpoint examples and php files). Those endpoints need to be called by Kodi when the events occur. For this we use the xbmc.callbacks2 plugin
Fill in the details that have been requested and click ‘Done’
Go back to ‘Things’ and you will see your Kodi device there
Go to app settings and enable OAuth
Click ‘Publish → For Me’
Install the device
Select desired switches to control along with desired light levels for each event type (value of 101 will restore to last known level)
Optionally name this instance of the app,assign icon, and modes to operate in
Scroll down and click the View URLs link
On following page the app should display 4 URLs, one for each event type. Copy these down and click done.
Install the xbmc.callbacks2 plugin for Kodi/XBMC
Open the settings for the callbacks2 plugin to the playback menu
Set events to the corresponding URL you copied from the app
If you are having any problems, please uninstall the SmartApp, goto the IDE (where you installed the devicetype and SmartApp code) and click the ‘Logs’ button. Reinstall the SmartApp via your mobile phone and post the logs here for me. Please ensure you check the logs for your username and password before posting!
Massive credit to @iBeech as this is heavily based on his Plex Manager
Also massive credit to @thildemar for hit callback controls.
Had a quick minute to test but getting an error on setting up first kodi device:
error java.lang.IllegalArgumentException: The JSON input text should neither be null nor empty. @ line 101
debug No Devices found, adding device
debug getChildDevices(false), children=0
debug Checking to see if the client has been added
debug Installed with settings: [clientName:Kodi, kodiIp:192.168.1.40, kodiPort:8080, kodiUsername:Kodi, kodiPassword:kodi, theHub:physicalgraph.app.HubWrapper@5dc40efb]
error java.lang.IllegalArgumentException: The JSON input text should neither be null nor empty. @ line 101
debug Received Response: devicetype:04, mac:0024BEF7E20F, networkAddress:0A0A0A0C, deviceAddress:C351, stringCount:04, ssdpPath:/Ircc.xml, ssdpUSN:uuid:00000000-0000-1010-8000-0024bef7e20f, ssdpTerm:, ssdpNTS:ssdp:alive
debug Received Response: devicetype:04, mac:0024BEF7E20F, networkAddress:0A0A0A0C, deviceAddress:C351, stringCount:04, ssdpPath:/Ircc.xml, ssdpUSN:uuid:00000000-0000-1010-8000-0024bef7e20f, ssdpTerm:, ssdpNTS:ssdp:alive
Are there any version requirements? I run nightly builds of Kodi (17)
I’m getting the same, but with the current stable version. I’d also like to suggest that user/pass not be required since it’s not unusual for folks to run without those…
error groovy.lang.MissingMethodException: No signature of method: script14544303185621739234675.setPlaybackState() is applicable for argument types: (java.lang.String) values: [stopped] @ line 51
debug Querying playback state of 192.168.1.40
11:38:24 AM: debug no player id
11:38:24 AM: debug Setting playback state to: stopped
11:38:24 AM: debug raw body: [{“id”:1,“jsonrpc”:“2.0”,“result”:},{“id”:1,“jsonrpc”:“2.0”,“result”:{“speed”:1}},{“id”:“VideoGetItem”,“jsonrpc”:“2.0”,“result”:{“item”:{“album”:“”,“artist”:,“episode”:-1,“fanart”:“”,“file”:“”,“label”:“”,“season”:-1,“showtitle”:“”,“streamdetails”:{“audio”:,“subtitle”:,“video”:},“thumbnail”:“”,“title”:“”,“tvshowid”:-1,“type”:“unknown”}}}]
its working for myself, i think i may have overlooked some variables that may change between kodi installations.
if i have some full logs i can see if there is a difference.
however since i’ve got home it seems that my home smartthings setup has got slower. eg lights taking longer to come on after motion.
this may be due to the constant polling of kodi…
going to run it for a few days and see. let me know if you see that same issues.
@TheFuzz4 i’m using a kodi plugin to control the hues outside of smart things.
I use rule builder to control the lights via motion sensor, it then checks to see if kodi is playing or pause. if it is is does nothing. if kodi is not playing/pause it turns them on.
@toliver182 is rule builder another smart app similar to rule machine? Off to the search.
Edit: Ok found this thing https://www.simplerulebuilder.com/ simple enough now to see if it works tonight. Might have to hit up @bravenel and see if the kodi device type can be integrated into rule machine.