[RELEASE] Kodi for SmartThings BETA

Thanks for the additional details - it’s interesting to hear that it doesn’t work on any of your Android boxes on so many variants of the OS. I’ll have to see if I still have the Android VM that I tested this on and may have to spin up some new VMs to test. I’m curious what changed as this was working with at least some variant of Kodi on Android at one point.

Yes, I have the uPNP enabled, as well as the remote / HTTP stuff. Neither the Windows 10 PC nor Android (Ouya) passes discovery.

(I can control and interact with Kodi on the Ouya using Yatse, FWIW)

I just deleted all my Kodi devices and went through the discovery process through the SmartApp and noticed the same thing was happening to me as well. I would hazard a guess that something changed with a recent SmartThings platform or mobile app update. I was able to create the devices by checking the boxes for the desired devices, then tapping Done and then immediately tapping Done again before the next discovery cycle occurred.

The alternative is to manually create your devices using the SmartThings IDE, then manually configure the IP address in the device’s settings.
http://graph.api.smartthings.com → My Devices → New Device → Type: Kodi Media Center → [Create]


Note: Also enter in a name for the device (eg. Kodi Main), a network ID (eg. KODI_MAIN), and select your Location and Hub.

Since you are already in the IDE, you can edit the device preferences… or you can edit the device preferences in the mobile app by selecting the device from the Things list and then tapping the cog icon to edit the device preferences.

1 Like

Ok, looks like rapidly hitting done twice managed to get them added, and I’m able to use the remote control on both devices now! Thanks for the tip.

(Any idea if it will also interface with amazon’s Alexa somehow? I can directly control my z-wave light switches through the Samsung smartthings app using voice commands through Alexa on the the Amazon Echo Dot)

I was looking to control lighting based on the type of media being played (i.e., I only want to dim the lights when playing a movie but not a TV show). I’m not sure if this was this was the best method, but it did appear to be least change-heavy way. I guess it’s also possible there’s already something in the code that I would be able to leverage, but I wasn’t able to find anything. I added a new attribute called “trackType” and set the attribute to the value held in itemClass when the metadata comes in on a changed state. Then in CoRE, I only trigger when the value is “object.item.videoItem.movie”. TV Shows appear to be “object.item.videoItem.videoBroadcast”. Thoughts on this method?

A couple of related issues of note. I also use the MythTV PVR plugin with Kodi, but unfortunately it appears that it doesn’t send over a video type in the itemClass, and instead just uses a generic “object.item.videoItem”. Kodi has access to this type of metada in the guide info, so it should be relatively easy to forward that out over the UPnP messages, so I might ping someone over on that side for that. I’m also running the latest beta for Krypton on one of my Kodi boxes, and it appears that when a movie is launched from one of the “Smart” groups (recently added, in progress, unwatched, etc) the metadata comes across blank in the UPnP message. Again, not something that can be fixed on this end, but something to be aware of.

Need to install this instead [Release] Kodi Manager - playing status and control
Harder to install but well worth it as its kodi telling smartthings something has happened. Then create these in CoRE

1 Like

I use this smart app and none other to do something kind of similar. The tv in my bedroom resumes it’s state after losing power so I leave it on and use a smart plug to turn it on and off. With the use of this smart app I can get the state of kodi from OSMC on a raspberry pi 2 and with CoRE (you have to set it as a music player for it to work) I have programmed the tv to turn off after 5 minutes of changing to paused or stopped. For those nights my fiance falls asleep watching TV, and by those nights I mean every night lol.

This can help as a template to do what you need.

1 Like

This app is also Kodi telling smartthings that something has happened, but in a much cleaner fashion. Smartthings is subscribing to Kodi events via UPnP, and when an event is registered, Kodi sends a message to Smartthings. I’m actually quite happy with the way Kodi for SmartThings is working, especially because it only relies on the native features already in Kodi and doesn’t require an add-on. Your response doesn’t address what I was looking to do- differentiating between types of media being played such that they are handled differently. I have already implemented this by making a very small change to the Kodi for SmartThings code, and was just looking for a peer review if that change was appropriate.

2 Likes

It sounds like a reasonable approach to me. videoItem.movie should be a Movie and videoItem.videoBroadcast should be a TV show per UPnP specs. If you’ve already made the code changes, feel free to submit a PR.

Unfortunately, UPnP isn’t always treated as a first-class citizen by Kodi, so we end up with issues like the ones you mentioned. :expressionless:

1 Like

Just submitted the PR. Do you have a link for the document you pulled that from? I was poking around a little to find the spec but came up empty-handed.

PR has been merged. Thanks!

I was looking at the UPnP ContentDirectory service document (Appendix C, 7.2).

1 Like

Love github integration in ST updated without issue.

I’m also curious to see what this does with my kodi st issues with android. Would be interesting if it fixes it

are you referring to uPNP not working and sending events?

Yeah I figured it probably has nothing to do with this but its worth a hope :slight_smile:

I was playing around with video mirroring yesterday and I noticed that it didn’t work on android TV but works flawlessly from windows to windows. I know that requires uPNP as well, I wonder if there is any relation to it.

unfortunately, the change I made isn’t really related. I just made a value that was already available inside the device handler and made it available to outside Smart Apps. I mentioned this over in the github issue as well, but I’m running AndroidTV OS on a Shield Android TV and everything is working fine. It really is an interesting combination of working/not working. My SATV works but there are reports that the Nexus Player (which is quite similar to the SATV) does not. “Normal” Android works for some but not all. And for others, it’s working on PCs but not on Android on the same network, likely ruling out a router configuration problem. Just to be sure, you did enable the “Allow remote control via UPnP” option in Sytem->Services->UPnP menu of Kodi, correct?

Yeah mine was working when I had it running on a Ubuntu box but I just retired that box in favor of the android box :slight_smile: You know less power draw and the such and just easier to manage. I agree that the work/not work is quite odd. I’m going to have to upgrade the rest of my android boxes in the house because Kodi17 requires Android 6 or higher and since I like to stay up to date my MXQ boxes won’t be. We also have a MySQL DB for all of our kodi boxes to keep tabs on what was watched so we can move from one TV to the next without losing our place. Oh the spoiled world we all live in.

1 Like

I think you mean version 5 :wink:

http://kodi.wiki/view/Kodi_v17_(Krypton)_FAQ#Android_5

Also, guys if you are using Kodi on Android just use SPMC it contains lots of fixes specific to Android. If you don’t know what SPMC is think of it as Kodi for Android as the original Android developer who left Kodi maintains this with specific Android fixes. This solved some audio and SMB issues I had once I installed it so can’t recommend it enough.

@dshokouhi yeah I meant android 5 lol. I’ll have to check out sbmc. Do you know off hand does it work with MythTV?

SPMC does work with the mythtv pvr plugin. As far as I know, all plugins for Kodi should also work in SPMC. The differences between Kodi and SPMC are primarily centered around hardware support.

1 Like