joshualyon / ST-Kodi

Kodi for SmartThings - Device Type and SmartApp
Apache License 2.0
12 stars 12 forks source link

UPnP Eventing Issues (Kodi Android) #6

Open jerryseigle opened 7 years ago

jerryseigle commented 7 years ago

I can control kodi using the remote from the Smartthings app. However If I use the remote that come with the Amazon Fire Stick or if the video has finished playing the Smartthings Kodi app does not update and change status.

Also I have light automation to dim the lights when video is playing and to turn back on 100% when video has stopped. I like to know if you can change the switch type instead of On and Off can you fix it where I can select different light automation for when a video is Playing, one for Pause and another one for Stop

TheFuzz4 commented 7 years ago

This appears to be an Android related issue as I recently put an Android box on my living room TV and st no longer detects the status change. I created a piston inside core that will refresh and poll the status every minute as a work around. I'm not sure why with Android it has an issue detecting status changes vs a PC. Before my PC died it detected the changes in the status right a way

jerryseigle commented 7 years ago

Two more questions:

  1. As you mentioned that you "created a piston inside core to refresh and poll the status every minute," can I change the refresh rate for example instead of one minute can I change it to every 30 seconds or less?

  2. Can you add to the smart app or tell us how to do the following.

I have a lighting automation that monitors the Kodi Smart app as a switch. Playing is detected as a switch being on and pause and stop is detected as a switch being off.

I would like to setup a lighting automation that will turn lights off when movie is playing, brighten light a little if movie is paused and turn on 100% if movie has stopped. The only way I can see this is by using modes. Can you please add into the smart app to display all of the available modes then allow us to choose different modes for when a video is playing, a different mode if a video is paused, and a different mode if a movie has stopped?

TheFuzz4 commented 7 years ago

@jerryseigle I am not the developer of this I'm just a user like you :) so I don't have a way of changing this. I just know that it is directly related to Android devices. I also have a CORE Piston that is running to dim my lights based off of the status of Kodi.

Look at my pistion in this thread https://community.smartthings.com/t/release-kodi-for-smartthings-beta/38305/117?u=thefuzz4 as this shows you how I set it up to watch the status of kodi and adjust the lights based off of what kodi is currently doing. Thanks.

joshualyon commented 7 years ago

Automations based on playing status

It looks like @TheFuzz4 has you covered with the automation based on status. Specifically, you have to use a SmartApp which can recognize the status attribute of your Kodi virtual device as that attribute has the playing, paused, and stopped attributes.

Fire TV status updates

Regarding the the updating of status of the Kodi virtual device based on physical remote control changes, this works fine for PC based installations, but some Android based installations like the Nexus Player and Amazon FireTV have issues with UPnP (post reference). This SmartApp and Kodi are both open source, so feel free to do some debugging and submit a PR with your changes if you find an issue.

From my initial debugging, this seems to be an issue with specific Android implementations and the UPnP events being blocked, so my initial thought would be to check to see if something on Fire TV/Android TV is blocking the events.

The alternative for these specific device types would be to use an HTTP POST AddOn in Kodi (triggered based on status events) and then add Web Service EndPoints to the Kodi SmartApp... this would be a manual configuration, but could be a temporary workaround for the unsupported devices.

TheFuzz4 commented 7 years ago

Created this over at Kodi as well http://forum.kodi.tv/showthread.php?tid=298318 lets see if perhaps they have some Android ideas here. The general consensus that I've come across is that they all say UpNp sucks lol so perhaps I'll have to get my feet wet and look at the code here and see if there is a better way to poll the status from Kodi.

jerryseigle commented 7 years ago

Great! Thanks for your speedy reply.

joshualyon commented 7 years ago

You can definitely poll Kodi for status and the DTH includes code for this. The poll() method maps to the refresh() method which makes an HTTP web service call to Kodi to get the current player status and then has a few follow up HTTP calls once it receives the response to get detailed status based on the returned active player.

While UPnP wasn't my preferred initial approach for this, it was the lowest common denominator between SmartThings and Kodi to achieve push events from Kodi and maintain automatic configuration (eg. not making the user install an AddOn to Kodi and configure it). Granted, the user does need to have certain settings enabled in Kodi, but these are commonly open if they are already using remote control apps like Yatse, etc.

I would be curious if this is an Android issue or a Kodi on Android issue - again, it only seems to be limited to specific configurations as it works on a stock Android devices (as shown here from Feb 15).

joshualyon commented 7 years ago

@TheFuzz4 noted that this is impacting him on other Android boxes running various versions of Android, so it doesn't seem to be limited to Android TV as I initially thought.

Yeah I have some MXQ boxes and 1 of these http://a.co/iJgDt5B which btw blow those MXQ's out of the water.

But I have the same experience with ST and Kodi across the board with all 5 android boxes that I have in my house so it is a little more spread out than just a few devices I don't think that its related directly to the box itself I do think its something to do with Kodi on Android. My MXQ boxes are on I think either 5.0 or 4.4 android and the N35 is on 6.1 i think ( I dunno it got an update first thing after I plugged it in) but anyways thats my thoughts on this

borikarloff commented 7 years ago

I paid $ 100.00 for my Kodi Box and I would like to know why when I pull up certain movies, for example, all the movies of Jack The Ripper, when I click OK on the remote it says not Available, why is that or it might say no streaming. I was under the impression that the purpose of having this box was to be able to watch what ever you wanted to watch and I am not finding that to be the truth #5

joshualyon commented 7 years ago

@borikarloff I think you may be looking to comment elsewhere? This is code for the SmartThings hub to interface with the Kodi media center software. If you have trouble with a Kodi box, you need to contact whoever you bought it from or post on the Kodi forums.

astephon88 commented 7 years ago

Just to add another data point, I'm running on an nVidia Shield Android TV box (running Android TV 6.0) and the UPnP is cooperating just fine.