[OBSOLETE] Kodi for SmartThings BETA

The Subscribe/Unsubscribe events use the UDN IP address and UDN port which is set in the setupDevice method which is only called from the supporting SmartApp. After the IP address is manually updated in a device’s settings, it calls the initialize method which calls setURL to override the base HTTP URL and CheckEventSubscription after a 5 second delay but does NOT call the setupDevice method as it requires parameters only found during the SSDP discovery.

We could probably change the udnAddress to match the overridden HOST component of the URL you entered, but note that the udnPort for UPnP event subscriptions is different than the HTTP port and is only determined by the SmartApp during discovery (not the device handler).

My concern here is that Kodi is reporting the wrong UPnP address during discovery for some reason and really that should be fixed instead of putting a shim in place to grab the host from the overridden URL. As others have mentioned, I’d love to have more feedback from the Kodi team as to why there are some odd issues like this, but I don’t think UPnP eventing is a high priority item for them.

2 Likes

Setting the url and port is still not finding the Kodi…

It may not be finding it but did you try the controls in the smartapp to see if they work? Like if you play a file in kodi can you pause it from the ST app? The issue we are having is with discovery and uPNP (uPNP is basically if you start a file on kodi does the app show that you started playing something).

The webserver which you configured using IP and port gives you control but uPNP gives you the events so you can react upon them.

Now also make sure that when you edit the device in the ST app that you are entering the username and password configured for the webserver in kodi. By default the username is “kodi” and the password is left blank.

Kodi v16.1 is installed on an HTPC. This app is working in both directions.

My Kodi is not always on so when I close it, the app still says that Kodi is “Now Playing” either paused or a green on with the title of the last movie we watched.

Is there a way to update the Kodi app to tell it that Kodi is not on and not playing anything?

Also I can get Kodi to start from a PC “off” status using WOL and Event Ghost.

Took a little bit but I can tell Alexa to start Kodi, then magically my HTPC turns on, TV turns on, both AVRs turn on, Lights dim to 20%, and movie volume is applied. Pretty darn cool.

Once I press play then all lights turn off, ST is set to Movie Time!

Is there a way (third party app maybe) to tell Kodi which movie to play? This would complete this automation.

Thanks again.

1 Like

Kodi updated to version 17 Krypton. It’s a cleaner looking version than Jarvis.

There are some “hacky” solutions out there with Tasker. I have almost the same setup as you, and did the Tasker solution with Yatse integration, and didn’t love it. Yatse is a really good Kodi remote, but it also has the ability to search and play movies with voice commands. So, essentially, the solution that I use is:

Google Home: “Hey Google, cinema VARIABLE”
IFTTT: GH Variabel to Maker Channel
Maker channel sends variable to Join API
Tasker picks up Join info and opens Yatse and accesses Yatse API
Yatse “types in” the VARIABLE from IFTTT (such as “Play Wedding Crashers” or “Pause movie” or whatever)
Kodi does its shit

Here is the Reddit thread I got it from: Reddit - Dive into anything

But again, I don’t love it because it HAS to use an android phone or tablet to control Kodi. So, if you are using it to play games or text or whatever, then Tasker basically kicks you out.

Yatse would have been my recommendation as well.

I build a node.js app that responds to web requests containing a movie title, looks it up in the library, and sends the appropriate command to Kodi to play. Works pretty well for me, you might be able to customize for your environment. Alexa may be a limitation though, I count on the ability to pass part of the IFTTT Google Assistant voice command through to a Maker web request as a variable, and I don’t think the Alexa IFTTT integration allows that.

My use case is Google Home voice command → IFTTT → CoRE → node.js app → Kodi

Joshua_lyon

Thanks for the nice app. I have only partial success with it so far. your smart app is able to correctly poll the title that is playing, but i wasn’t able to control the player. I have tried all the above mentioned options multiple times i.e, remove, republish etc 3-4 times but no progress.

My setup is Kodi V16 on windows PC and am able to control kodi using using Yatse on my phone and also iRule on my tablet. I have done multiple discoveries and the app was able to discover Kodi PC , but it looks like uPnP event subscriptions are not happening properly.

I am assuming you are calling the json-RPC methods in your device handler. I can post the logs if it offers some light.

Here is the log after Refresh from the smartapp

194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:08 AM: debug Returning 1 HubActions
194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:08 AM: trace SUBSCRIBE 192.168.1.136:1207 to /AVTransport/7b482563-c3b1-56b2-51e6-6fa80f9852fd/event.xml
194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:08 AM: trace subscribe(/AVTransport/7b482563-c3b1-56b2-51e6-6fa80f9852fd/event.xml, )
194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:08 AM: debug Refreshing subscription for: [:]
194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:08 AM: debug Unsubscribing from and removing: [:]
194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:08 AM: debug Checking for expired subscriptions in [:]
194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:05 AM: trace Sending command: Player.GetActivePlayers
194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:05 AM: trace SUBSCRIBE 192.168.1.136:1207 to /AVTransport/7b482563-c3b1-56b2-51e6-6fa80f9852fd/event.xml
194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:05 AM: trace subscribe(/AVTransport/7b482563-c3b1-56b2-51e6-6fa80f9852fd/event.xml, )
194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:05 AM: trace Clearing existing event subscriptions and getting a new subscription.
194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:05 AM: debug Getting status from 192.168.1.136:8080
194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:05 AM: debug Executing 'refresh’
194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:03 AM: debug overriding the IP Address based on input preferences null
194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:03 AM: debug updated
194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:03 AM: debug overriding the IP Address based on input preferences null
194f9e2b-f41c-4187-b1b4-91b42655e780 1:24:03 AM: debug updated

Quick heads up…The latest version of SPMC, 16.6.0, appears to have partially broken the UPnP subscriptions (at least on SATV). The device handler is still registering play and pause events, but stop events are not making it through. the SPMC changelog mentions “ADD: zeroconf via API”, and the UPnP configuration menu in SPMC has changed slightly. It now has an option in the UPnP configuration for Airplay, which makes me think something got mixed up in the change. Rolled back to 15.5.5 and all is well again

I set this up today and it works great. Just that Im watching tv through IP-TV Simple Client on Kodi and it does not support pause command. When i stop the stream with my regular remote the DH updates to “stopped” though. I also tried to send a stop-command from CoRE but it only tries to pause it then. Is it anything i can easily change in the DH to get the pause command replaced with a stop command?

Play and Pause both send the Player.PlayPause command which in theory should toggle the media playing but keep it on screen.
Stop sends the Player.Stop command which should stop and end the media.

The commands are available on the Kodi wiki if you want to try mapping others:
http://kodi.wiki/view/JSON-RPC_API/v6#Player.PlayPause

1 Like

Ah ok Thanks! How do I, by the way, read status etc from Kodi in COrE? CoRE asks for a parameter when i choose Kodi media controller as a trigger? I would like to ger status if Kodi plays a stream/file and automate from that.

Nevermind, found the info on your github. Thanks!

1 Like

Since the upgrade to Krypton (17), I no longer get any information about the status of the media player (device powered on, media playing, etc). The buttons do work however and I can navigate with the arrow keys and select.

1 Like

Are there any forks for this or comparable software? Its looks like @joshua_lyon has abandoned this software and hoping to find a working alternative.

Thanks

The code is open source and available on GitHub. You are welcome to debug it and contribute back and I am happy to accept Pull Requests.

1 Like

This might sound derpy, but I’ve got this all installed, but… Now what? I want to have Kodi pause when someone presses the button on my Ring doorbell. But I can’t for the life of me find where in the ST app to do that! Create a routine? That only gives me the option of turning on lights. I’ve got Kodi and Ring in my devices, but I can’t seem to get much further than that!

Howdy there @fireaza. The time has come for you to look at WebCORE. We all built custom pistons in webcore to accomplish exactly what you’re looking to do. https://wiki.webcore.co/ there are lots of threads here in ST for webCORE and the community will gladly help you along your way.

I also have mine setup to pause playback if the doorbell rings as well as adjust the lights depending on what the status is play/pause/stop

I hope that this helps you and once you see everything you can do with webCORE its going to enhance your ST experience 1000% it allows you to do things that you didn’t even know ST could do.

Edit: Here is the forum section in ST for this https://community.smartthings.com/c/smartapps/core

2 Likes

Ah, so I can’t do it after all? I thought I was overlooking something obvious! But that WebCORE sounds nice! SmartThings is great, but a little more power would be good! Is it a somewhat simple process to add a “piston” that someone else has already made?