[OBSOLETE] Kodi for SmartThings BETA

I got it installed from removing MediaRenderer and the other Kodi device. I also can not get play and pause to work… everything else seems fine. My Now playing is blank. Before I put in my user name & password it showed the current playing song.

One thing to make sure you pay attention with the username and password is that the app will put in the first character for both as capitalized. If it’s lowercase, you have to manually click the shift arrow to undo it. This is at least true on Android and bit me last night the first time.

1 Like

That was it (port)…I had borked the setting accidentally deleting the 0 when I was in there before. Set it back to 80, and now the SmartThings Device control page seems to be working fine.

Thanks!

1 Like

I’m seeing two entries for “Media Player” (what I set the name to).

In the Things list, one says Stopped, the other 0.

If one is valid and the other seems to be a duplicate, you can safely delete the duplicate device. If you can figure out how to reproduce this, let me know and I’ll look into it.

I would follow Brian’s advice and check that the username and password are entered correctly and make sure that the URL shown at the bottom of the device screen in the mobile app (or in the destURL field of the device details screen in the IDE) is the correct destination URL.


The destination URL should be set based off of what Kodi reports during the device discovery process. If this is incorrect, I would be curious what is wrong about the reported URL and what you guys are having to change to get it to work.

If it’s just the username and password that are missing, the device should be showing a message in the status field at the top of the device UI when you first try to use any of the buttons. This message should tell you to edit the device and enter your kodi credentials.

Any update on Rule Machine being able to work based on playback modes etc?

I believe you requested it just wasn’t sure if you heard back

Hi

This is what I’m getting with the play and skip buttons… the others seem to be working fine. I’ve double checked my login and IP. I have Yatse running fine on 4 other tablets so I think my Kodi is set up right. Let me know if I can try anything.

Thanks

844b5940-191f-4354-b498-996624076741 8:16:51 PM: debug running todos
844b5940-191f-4354-b498-996624076741 8:16:51 PM: debug Last Command: Input.Right
844b5940-191f-4354-b498-996624076741 8:16:51 PM: debug [id:1, result:OK, jsonrpc:2.0]
844b5940-191f-4354-b498-996624076741 8:16:51 PM: debug HEADER: [content-length:38, http/1.1 200 ok:null, cache-control:private, max-age=0, no-cache, connection:Keep-Alive, accept-ranges:none, content-type:application/json, date:Wed, 10 Feb 2016 01:11:14 GMT]
844b5940-191f-4354-b498-996624076741 8:16:51 PM: trace Response Received (with Headers and Body)
844b5940-191f-4354-b498-996624076741 8:16:49 PM: trace Sending command: Input.Right
844b5940-191f-4354-b498-996624076741 8:16:29 PM: debug running todos
844b5940-191f-4354-b498-996624076741 8:16:29 PM: debug Last Command: Player.GoTo
844b5940-191f-4354-b498-996624076741 8:16:29 PM: debug [id:1, error:[message:Failed to execute method., code:-32100], jsonrpc:2.0]
844b5940-191f-4354-b498-996624076741 8:16:29 PM: debug HEADER: [content-length:86, http/1.1 200 ok:null, cache-control:private, max-age=0, no-cache, connection:Keep-Alive, accept-ranges:none, content-type:application/json, date:Wed, 10 Feb 2016 01:10:53 GMT]
844b5940-191f-4354-b498-996624076741 8:16:29 PM: trace Response Received (with Headers and Body)
844b5940-191f-4354-b498-996624076741 8:16:29 PM: trace Sending command: Player.GoTo
844b5940-191f-4354-b498-996624076741 8:16:29 PM: debug Executing 'nextTrack’
844b5940-191f-4354-b498-996624076741 8:16:07 PM: debug running todos
844b5940-191f-4354-b498-996624076741 8:16:07 PM: trace UPnP Response
844b5940-191f-4354-b498-996624076741 8:16:07 PM: debug HEADER: [nts:upnp:propchange, nt:upnp:event, content-length:369, sid:uuid:0f0ff704-cadf-ef27-c0e5-f3236983c673, host:192.168.1.6:39500, seq:6, user-agent:Neptune/1.1.3, content-type:text/xml; charset=“utf-8”, notify /notify http/1.1:null]
844b5940-191f-4354-b498-996624076741 8:16:07 PM: trace Response Received (with Headers and Body)
844b5940-191f-4354-b498-996624076741 8:16:06 PM: debug running todos
844b5940-191f-4354-b498-996624076741 8:16:05 PM: debug Current playing title is: 25 Or 6 To 4
844b5940-191f-4354-b498-996624076741 8:16:05 PM: debug METADATA: 25 Or 6 To 4ChicagoChicagoChicagoChicagoUnknownChicago IX - Greatest HitsClassic Rockhttp://192.168.1.101:1455/thumb?path=image%3A%2F%2FD%253a%255cMusic%255cChicago%255cChicago%2520-%2520Chicago%2527s%2520Greatest%2520Hits%255cFolder.jpg%2F12016-02-07T20:50:36+05:004600.0object.item.audioItem.musicTrack
844b5940-191f-4354-b498-996624076741 8:16:05 PM: debug WE HAVE METADATA

Bruce added this to 1.7.10 today!

1 Like

Sorry that it’s not working as expected! I’m out of pocket for the next few days, but I’ll see if I can test this more thoroughly this weekend. Per your logs, I see the nextTrack (Player.GoTo) is failing in Kodi, so I’ll need to double check the implementation. eg. It looks like Kodi is receiving the command but is replying that it failed to run it for some reason.

I didn’t see the play command in your logs. Is it responding with the same error messages?

PS. When posting the logs, you may want to highlight the text in your post and click the </> button to format it as logs so it is easier for others to read through this topic. Alternatively, you can paste the logs to pastebin.com and then share the link here.

PPS. I need to do some more work on the audio integration… for example, the Refresh button only gets the full status for video and not audio. I haven’t done a ton of testing with the Audio side of Kodi, but I’ll take a deeper look.

No worries… and thanks for the info on log posting.

Thanks

Another thing I noticed - right now I have a movie playing in the theater but the “things” page is showing “stopped” if I go into the device I see now playing… The things view should show playing I would think and it be nice if it went green for example.

In the latest code from GIT I see this already in there

 private Boolean canInstallLabs()
{
//return hasAllHubsOver("000.011.00603")
return true
}

But I’m still getting the upgrade notice when I try and install the app. Any tips?

Edit: Nevermind its late and apparently I’m suffering from a lack of reading :slightly_smiling:

Ok so I’ve tried to get this to see 3 of my Kodi boxes. All 3 of them have the web server enabled and running on the default 8080 then I also enabled the UPnP section as well but watching the logs where its issuing the SSDP request nothing ever shows up. Is there something else I"m missing?

2 of my Kodi machines are Android MXQ boxes and the 3rd is just a simple ubuntu machine. Thank you all for this can’t wait to get it completely setup.

1 Like

Do you already have these Android MXQ or Ubuntu machines configured as devices elsewhere in SmartThings? For example, a user above noted that they could not discover their Kodi machines if they were already added as devices using another SmartApp in SmartThings (eg. Media Renderer).

Can you post the SmartApp logs from during the discovery (via Pastebin) so I can see what messages are being displayed?

If you really want to dig into it, you can sniff the network traffic on the Android devices or Linux box while the SSDP discovery is occurring and confirm that the boxes are receiving the discovery request and are responding. To make it manageable, you would likely want to filter to just the traffic going between the Hub and your device (eg. set filters on the source and target IP addresses).

Also, just to make sure we are on the same page, you have the Allow remote control via UPnP option checked, right?

I did have the Ubuntu machine and one of the MXQ were being controlled by a previous Kodi implementation where I had to manually specify the IP. However the other MXQ and I even enabled UPnP on my ubuntu desktop in Kodi as well just for a good measure.

Here is the log snipit just keeps repeating the same messages. I am on v1 of the hub as well. Thanks @joshua_lyon for your help with this.

http://pastebin.com/swxwpd9h

For the ones that were being controlled via a previous app is there something special I need to do to them besides deleting the device from ST?

EDIT: Here is a tcp dump from my desktop
http://pastebin.com/1CCZYYRN

Successful SSDP discovery logs in the SmartApp would look something like the following:

9:35:37 PM: trace Created Kodi (GamingPC) with id 'MACADDRESS', IP '192.168.1.84', PORT '1084', UDN '5d80d852-2aa2-2cc5-d025-68d1f4764bfd' and url http://192.168.1.84/
9:35:35 PM: debug uuid:5d80d852-2aa2-2cc5-d025-68d1f4764bfd::urn:schemas-upnp-org:device:MediaRenderer:1={model=Kodi, ssdpUSN=uuid:5d80d852-2aa2-2cc5-d025-68d1f4764bfd::urn:schemas-upnp-org:device:MediaRenderer:1, networkAddress=C0A80154, ssdpNTS=null, mac=MACADDRESS, deviceAddress=043C, hub=568201e4-43f7-4ada-923e-c3a246d69a96, ssdpPath=/, ssdpTerm=urn:schemas-upnp-org:device:MediaRenderer:1, url=http://192.168.1.84/, stringCount=04, verified=true, manufacturer=XBMC Foundation, name=Kodi (GamingPC), devicetype=04}
9:35:35 PM: trace These are being installed: [MACADDRESS]
9:35:35 PM: trace Adding child devices
9:35:35 PM: trace initialize()
9:35:35 PM: trace Updated with settings: [selecteddevice:[MACADDRESS]]
...
9:33:08 PM: debug Found marantz:[NR1602] (NR1602 by Marantz)
9:33:08 PM: info parseDESC()
9:33:07 PM: trace [deviceDiscovery] Discovered devices: [MACADDRESS:Kodi (GamingPC)]
9:33:07 PM: debug Verifying 1 devices
9:33:07 PM: trace There are 1 verified devices
9:33:06 PM: trace Found a Kodi device. Adding it!
9:33:06 PM: debug Found Kodi (GamingPC) (Kodi by XBMC Foundation)
9:33:06 PM: info parseDESC()
9:33:05 PM: trace parseSDDP() Adding Device "uuid:5f9ec1b3-ff59-19bb-8530-0006780d48ea::urn:schemas-upnp-org:device:MediaRenderer:1" to known list
9:33:04 PM: trace [deviceDiscovery] Discovered devices: [:]
9:33:04 PM: debug Verifying 1 devices
9:33:04 PM: trace There are 0 verified devices
9:33:01 PM: trace parseSDDP() Adding Device "uuid:5d80d852-2aa2-2cc5-d025-68d1f4764bfd::urn:schemas-upnp-org:device:MediaRenderer:1" to known list
9:33:01 PM: trace [deviceDiscovery] Discovered devices: [:]
9:33:01 PM: trace discoverDevice() Issuing SSDP request
9:33:01 PM: trace There are 0 verified devices

Note that in the above logs, the SSDP discovery is finding non-Kodi devices that respond to UPnP discovery – like my Marantz receiver – but it is only surfacing the Kodi devices for selection. In your case, it looks like the Hub+SmartApp aren’t finding any UPnP devices on your network.

Also, here’s a Wireshark dump filtered to just the traffic running between my PC and the hub.

Filter: ip.src == 192.168.1.118 || ip.dst == 192.168.1.118

Where 192.168.1.84 is the PC running Kodi and 192.168.1.118 is the SmartThings hub:

In the capture above, you’ll see that the Hub sends out an SSDP discovery broadcast to 239.255.255.250 on port 1900 and the Kodi instance responds with a UDP response to the originating port (10023). Normally, if you aren’t seeing the SSDP discovery requests, you would want to make sure that SSDP/UPnP/Port 1900 requests are not blocked on your network (eg. router, PC, etc).

Can you help me better understand the devices that are showing up in the tcp dump? eg. What is 192.168.1.145, 192.168.1.188, 192.168.1.168, 192.168.1.193, 192.168.1.220, 192.168.1.231, 192.168.1.232, 192.168.1.227 – it doesn’t look like this is filtered and without know what the devices are and what’s happening on the network at that time, it’s hard to follow what’s happening.

Normally, you shouldn’t need to do anything special other than remove the old device, but I have seen quirkiness with the platform that sometimes makes things like this more challenging than they should be. For example, I’ve seen other users have to force an IP address change of a LAN device to get it to be discoverable again. Personally, I haven’t experienced this.

Can you verify that the scheduler was still working? The scheduler is used to keep the event subscriptions working and when I checked mine tonight, it had not fired in a few days. The SmartThings scheduler has been really horrible over the past 2 weeks and it is impacting a number of SmartApps.

The second post in this thread has instructions on how to refresh the scheduler.

Once I manually tapped Refresh in the device (and manually triggered an update to the SmartApp), the main Things list was properly displaying the status of Playing or Paused. I like the idea of adding green coloring to the Playing status and I’ll work on getting that implemented.


Edit: I’ve also tried to fix the issue with canInstallLabs and hasAllHubsOver (issue on GitHub with notes). It looks like the VIRTUAL hubs were being returned for some users and causing the hasAllHubsOver check to fail as the firmware for the virtual hubs is just 0. Update your SmartApp with the latest code in the GitHub repository and let me know if this fixes things for you or if the manual change to return true is still needed.

One last thing. I am running Jarvis would that be an issue?

Looks like it may have been the scheduler - last run was 2/7 so I reset that.

the new code words around the virtual hub issue - nice work - I updated and installed no problem.

now if I could get rule machine to work with media player like I want I would be all set. it doesn’t seem to trigger on changing to play/stop - works fine if I use it as a switch - still working on that one.

thanks for the great work on this!

Joshua,

Got one more thing. I figured out the rule machine issue - essentially your devicetype isn’t sending the right call for the music player detection.
We need to add this:

sendEvent(name: “music”, value: “playing”) to when we detect something playing and same for pause,stopped etc.

This should allow rule machine to act accordingly.

Thanks!

For now I am using it with the callbacks version of the kodi devicetype as this seems to be the only reliable way to get a status since the scheduler is so unpredictable.

1 Like