Does anyone have Kodi connected to Hubitat?

We use Kodi rather than Plex for our main media centre PC.
With ST I was able to set rules that if a movie was playing I could set certain lighting etc..
This was done using the following GitHub - joshualyon/ST-Kodi: Kodi for SmartThings - Device Type and SmartApp for ST

I was wondering if anyone has a way of doing similar in Hubitat as I'm trying to get the last few things off ST?

Do you have Harmony?
I set mine based on the Harmony activity in use.

I do and I have that set currently but with ST I was able to use the attached SmartApp / Device to set Movie lighting when we watch a movie using the following options in WebCore

image

I may keep ST anyway once I fully migrate across as I think there are a few things that aren't going to work in Hubitat currently

Which are you using Phil? I see a couple on ST forum.

This is the one I was using that the tracktype reporting works on

Kodi has an exposed API (https://kodi.wiki/view/JSON-RPC_API/v9) that can be called using websockets. You could write a simple app (or driver, perhaps) that could subscribe to the websocket and report when a player has started playing a media item and then inspect the returned JSON and grab the media type.

1 Like

I used to use this with Insteon. It's just http get, so you could use it as an example.

http://www.smarthome.com.au/smarthome-blog/xbmc-insteon-add-on/

Looks like I need to learn how to write an App / Driver then!

Where to start lol...

Haven't ever done anything like this so will take a while to get my head around it.

1 Like

Did you try just porting? You can remove the tiles from the driver code, they are not used on HE. Change occurrences of physicalgraph to hubitat in the code.

I did on the one Kodi for ST Beta, I sorted the physicalgraph references and was able to get to save but was then throwing up errors so I played around with some stuff and made it worse so would have to start again :slight_smile:

If you haven’t already, post what the errors are and someone here should be able to help you sort it out.

1 Like

With the help of Roy over PM we have been able to get the App and Driver to install and I have then been able to get the driver to pause / play etc. But it isn't reading the state of the playing media.

I have got it to work by overriding the auto-discovery as this doesn't find my devices.

The error I'm getting is groovy.lang.MissingMethodException: No signature of method: user_app_boshdirect_Kodi__formerly_XBMC__195.parseLanMessage() is applicable for argument types: (java.lang.String, java.lang.Boolean) values: [mac:XXXXXXX, networkAddress:C0A801B4, deviceAddress:50, ssdpPath:/description.xml, ssdpUSN:uuid:2f402f80-da50-11e1-9b23-0017882d484c, ssdpTerm:urn:schemas-upnp-org:device:basic:1, ssdpNTS:, ...] on line 257 (onLocation)

Line 257 onwards is " def lanEvent = parseLanMessage(evt.description, true)" and is in the group as follows:

/**

  • Called when location has changed, contains information from

  • network transactions. See deviceDiscovery() for where it is

  • registered.

  • @param evt Holds event information
    */
    def onLocation(evt) {
    // Convert the event into something we can use
    def lanEvent = parseLanMessage(evt.description, true)
    lanEvent << ["hub":evt?.hubId]

    //log.debug "LAN EVENT: ${lanEvent}"

    // Determine what we need to do...
    if ( lanEvent?.ssdpTerm?.contains(getDeviceType()) )
    {
    parseSSDP(lanEvent)
    }
    else if (
    lanEvent.headers && lanEvent.body &&
    lanEvent.headers."content-type".contains("xml")
    )
    {
    def xmlData = new XmlSlurper().parseText(lanEvent.body)
    parseDESC(xmlData)
    }
    }

I used the same device type handler from Joshua in ST as well. I've never coded in groovy before, but I am willing to help, test, or any other way I can to keep this rolling. I would like to port this over too. This and alarmdotcom are my last integrations running on ST.

Can you post the driver and app here?

What is the best way to post the code on here?
I can copy and paste what I am using from my setup?

If you're going to post code here, make sure the authors are attributed unless you are the author. Highlight the code and click the </> icon (preformatted text) at the top of the compose window so it truncates the preview and makes a highlighted scrollable window within your post. This keeps the code formatted properly, avoids accidental special characters from getting inserted, doesn't force everyone to scroll and scroll and scroll through the post where the code was just pasted in place without using the preformatted text option.

Alternatively, post code you own in a github repo, and fork code you don't own to your repo and post the link here. But always keep accreditation to the original author in the code and respect their terms. If according to their terms, the code is not to be altered, copied or used outside of sharing the original code in its entirety, then contact the author and ask what exceptions they might make. Otherwise, always honor their requests and or specific licensing terms if they exist.

At this stage it is far from complete.

@jsykes @Ryan780

So far I have managed to get the app and driver to save, it doesn't automatically search for Kodi instances so this has to be set manually in the driver.

I am able to control Kodi from Hubitat so far and that is all.
I can send notifications to Kodi from the Hubitat web portal but not from Apps (i am using another driver for that)

What I would like to do is control lights based on videotype that is playing. I can do this with ST so am keeping ST connected for now....

Do you want what I have posting so you can take a look? This is edited from Joshua's ST code.

No thanks. I took the quick and dirty way out. I plugged my kodi box into a Zigbee energy monitoring outlet. That way, when I shut it down in the OS, it is detected in the outlet and can do other functions and turn itself off. Then when i turn the plug back on, the system knows that kodi is on. Not able to do anything by media type but I didn't really need that.

1 Like

I am an avid Kodi user. Any progress here with HE integration?

Since the thread died two years ago, probably not much.

Can Kodi send or receive http requests? If so, rule machine and/or maker api could be one way to integrate with HE.