[SOLVED] How to use the Kodi binding to start favourite playlist and individual title from sitemap

Platform information:
MacBook Pro, 8GB, i7 CPU, High Sierra,
Java™ SE Runtime Environment (build 1.8.0_25-b17)
openHAB 2.3, Kodi 17.6

I try to control Kodi from openHAB using Kodi Binding 2.2. Using the template .items and .sitemap I can start, stop play and move the cursor. However I would like to call a dedicated playlist / and or a dedicated title from my sitemap GUi. I started using the playfavorite command in .items and .sitemap (see below). Interesting enough in the control section of the PaperUI the selection of the favourites works, displaying the favourite playlists in a drop down menu, allowing me to select one, and kodi does load the according playlist. Adding the same item to my sitemap definition however does not work. No drop down selection appears. I have not found mapping nomenclature, which displays channel states as a drop down menu - if that was needed. However, shouldn’t sitemap at least display what PaperUI does when added as a default item to sitemap? Here my .items and .sitemap definition:

.items definition:
String myKodi_playfavorite “Play favorite” { channel=“kodi:kodi:myKodi:playfavorite” }

.sitemaps definition:
Default item=myKodi_playfavorite

I also was trying to use the playuri command, however it is not clear to me where in the .items definition to insert the URI. I have searched the forum and Internet for two days now, and have not found an example for this common use case. Any help appreciated.

Othmar

Here the screenshot of play favorite as it appears in the PaperUI control section, which I am unable to replicate in my .sitemap file.

paperuikodi

Use the Selection element in a sitemap:

Vincent, thank you for your reply. I tried selection before, but I could not get a mapping to work. The elements of the selection mapping are dynamic, depending on which playlists I have in my favorites. So how can I describe dynamic mappings for my selection element? But even when I just want to display the (static) elements I have in favorites, it does not work. I used the names of the playlists (e.g. Oldies, LateNight) see below - but no luck. (The selection choices are there, but Kodi would not do anything.) When I use the playlist name and its extension (e.g. Oldies.m3u) I get a syntax error. Do you happen to have something like this working? Thank you for your help. Othmar

Selection item=myKodi_playfavorite mappings=[Oldies=‘Oldies’, LateNight=‘LateNight’]

05

Use Oldies\.m3u in the map file
I am afraid but I don’t know of a way to create dynamic mappings

Hi Othmar,

Basic UI does not support dynamically populated Selection elements in sitemap in OH2.3. This feature has been introduced later. To make use of it you will have to upgrade to the milestone or snapshot version. Otherwise you have to wait for the next release.

Vincent, thanks again. Unfortunately the Java escape sequence is not accepted, but taken as syntax error. (See screen-shot) - Sitemap stops showing when trying it.

Christoph - thanks much for your hint. I will try to upgrade to the milestone version. - Any idea how I could at least make a static mapping for the playfavorite of the kodi binding work in 2.3? Or the playuri command?. Is there a syntax how to insert a parameter (such as the URI) in an item channel specification? In the kodi binding documentation playuri it is clearly spefified as:

playuri String Plays the file with the provided URI

so how can I provide the URI along with the item (or sitemap) definition?

Thank you for your support! Othmar

I will try to post an example for you but I do not have much time in the next few days.

You have to enable DEBUG logging for the Kodi binding (org.openhab.binding.kodi) to see the values to be used in your sitemap mapping. Watch out for a call to the “Favourites.GetFavourites” method.

Hi Chris,
I looked in the docs and couldn’t see anything about that. Do you have any pointers?
Thanks

Hi Vince,

Thanks,
After reading I don’t see how to configure items and sitemap for this feature.
And how would I change the list in a rule script?
I know we are going off subject here. Please feel free to pm me.
I would like to update the docs and maybe write a tutorial.

… or start a new topic. I too have read the referenced feature request and, like you, I couldn’t determine how to dynamically fill selection elements in a sitemap (BasicUI.) I would like to follow along with this discussion.

This is what the Kodi API should return - what you can see in the logs:

2018-12-02 08:02:27.049 [DEBUG] [i.internal.protocol.KodiClientSocket] - send message: {"jsonrpc":"2.0","id":17,"method":"Favourites.GetFavourites","params":{"properties":["path","window","windowparameter
"]}}
2018-12-02 08:02:27.060 [DEBUG] [i.internal.protocol.KodiClientSocket] - Message received from server: {"id":17,"jsonrpc":"2.0","result":{"favourites":[{"title":"My first title","type":"window","window":"videos","windowparameter":"url"},{"path":"url""title":"My second title","type":"media"}],"limits":{"end":2,"start":0,"total":2}}}

You pick the titles of your favorites and put them into a mapping:

    Selection item=myKodi_playfavorite mappings=["My first title"="What ever label you prefer for first item", "My second title"="What ever label you prefer for second item"]

Christoph,

I installed the latest 2.4 snapshot and playfavorite works like a charm! For reference to others:
This is my entry in .items:
String myKodi_playfavorite “Play favorite” { channel=“kodi:kodi:myKodi:playfavorite” }

This is my entry in .sitemap:
Selection item=myKodi_playfavorite

Very simple. The dynamic mapping feature is really powerful! Thanks for your excellent work!
Here the screenshot:

Christoph,

Now also the individual title selection works, using the nomenclature you proposed. Below for reference my .sitemap entry for two dedicated titles, which I can now select:

Selection item=myKodi_playfavorite mappings=[“NPR.strm”=“NPR”, “LateNight.m3u”=“LateNight”]

Maybe you can append this example (as well as the use of the dynamic mapping feature with 2.4) to the Kodi-Binding documentation.

Thanks again for your help! Othmar

Perfect. Thank you too. Let me know if you have any feature requests or new ideas to improve the binding.

Christoph,

one last thing. When I use the openHAB iPhone App (version 2.0.2) to control my openHAB Kodi controls, the dynamic mapping feature does not work. (The pop-up-menu in the app, which displays my favourites, is empty. The other Kodi controls (volume, move cursor etc.) work.

Othmar

Hi Othmar,

AFAIK each UI - so iOS APP - has to implement this feature separately. I would suggest to open an issue for it in https://github.com/openhab/openhab-ios/issues.

I opened an issue as you recommended. Thanks, Othmar