openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.88k stars 3.59k forks source link

[Chromecast] Please provide a way to launch App on chromecast #11065

Open execcr opened 3 years ago

execcr commented 3 years ago

Some libraries in javascript (like castv2-client) let you open an application on the chromecast device. Actually sending an AppID to the AppID channel chromecast:chromecast:xxx:appId does nothing,

Reading the code I've seen that is done only for the media Player (CC1AD845) to cast a video.

It would be nice to tell the Chromecast to launch Spotify because actually the chromecast in invisible to the spotify web API until is started from a Desktop Spotify App or Android Application, In this way it should be possible with a rule to cast Spotify on a Chromecast, actually is impossible. Thank you

lsiepel commented 1 year ago

Today i spend some time to look if this is possible. The binding uses this library for Chromecast: https://github.com/vitalidze/chromecast-java-api-v2 I managed to make the AppId channel writable. If you send an AppId to the channel, the app gets started. But unfortunately, you can only write appId's and i have not yet found a way to grab a list of installed apps from the chromecast. Only when you have this list it would be user friendly.

jlaur commented 1 year ago

Perhaps this could be parsed and used: https://clients3.google.com/cast/chromecast/device/baseconfig. Although bundling a file like this could turn into a maintenance nightmare. Perhaps documentation could be updated to describe how to simply obtain appId's of interest (i.e. start the app and watch the linked item being updated)?

lsiepel commented 1 year ago

First i though about a hybrid solution. Then you would have the json list as default and in case the app is not listed, some documentation on how to do that. But then i realised this list is HUGE and openHAB doesn't really support a searchable picklist or some default widget that can cope that list. So it would be better to have a list of just the used/installed programs. We could provide a link to this list in the documentaiton, atleast it is a (small) step forward.

wdyt?

lsiepel commented 1 year ago

@jlaur looking at replacing su.litvak.chromecast.api.v2 for org.digitalmediaserver.cast as the current lib doesn't look to be maintained anymore and the new lib is a fork of the first. Before i do some actual work on the binding, would replacing it be an option? It is available in maven repo, so i allready added it in mij dev environment to play with it. It is not a complete drop-in replacement, but it isn't to far off.

lsiepel commented 1 year ago

Implementing that fork wasn't that difficult and it does have some benefits. Unfortunately it does not offer a list of installed apps. It seems the API just does not support this.

There are some options:

  1. leave it as is. no way to start apps.
  2. make the channel writable and make the user send appId's to it.
  3. create a predefined (based on @jlaurs json) short list maybe complete with some user definable list from config
  4. create some kind of storage to hold a list of apps. As soon as an app is started it is known to the binding and stored. after some time it gets rather complete.

My personal preference would go to 4. as that would be the best user experience and maintainable. @jlaur wdyt? Technically it would be some Storage that is injected from StorageService in the ChromecastHandlerFactory

lsiepel commented 1 year ago

Created a solution with option 4. Initial tests are no good :-(. The Chromecast only accepts to start the build-in mediaplayer. all other app start requests are answered with a NOT_ALLOWED response.

So unless someone knows about a magic security setting or other, we are stuck here and can't build the enahncement requested. My efforts are here: https://github.com/lsiepel/openhab-addons/tree/chromecast-write-app