[KODI] Anyone able to get the genre of the currently playing movie using the Kodi/XBMC binding?

Hi there,

I am still running openHAB v1.8 with the old XBMC binding and I am trying to get the genre of the currently playing movie so I can decide whether to turn off the lights (e.g. don’t turn off lights if playing a family/kids movie).

But I can get the binding to retrieve the genre. Tried Label.VideoPlayer.Genre, Player.Genre, VideoPlayer.Genre and nothing is displayed.

Wondered if anyone else had cracked this?

Ben

It seems the new binding does not support this.
https://docs.openhab.org/addons/bindings/kodi/readme.html

For the old binding, you are right, it should work.

Player.<???>	<	Any other player property supported by the XBMC JSON RPC API

https://kodi.wiki/view/JSON-RPC_API/v8#VideoLibrary.GetGenres

I would try this:

Player.VideoLibrary.GetGenres

But you could get multiple genres in return and I don’t know how openhab will handel this.

Actually I don’t think it is supported. :frowning:

According to the wiki the binding only supports Player.* while you need VideoLibrary.GetGenres. Not Player.VideoLibrary.GetGenres

I created a feature request.
Maybe it will be added to the new kodi binding in the future.

Thanks for the feedback @christoph_wempe - good to get confirmation it is not just me! Thanks for filing the feature request too.

Dear all,

I am afraid I cannot help you with the old binding version.

I looked into the requirements for a new channel to deliver the genre information via the interface to openHAB. It will work but Kodi delivers a list of multiple genres for a media/audio file. The data can be converted to a semicolon separated String to be accessible at the channel, but I am personally not very convinced if that is a proper solution for it. Wdyt?

// Edit: I will post an example of the Kodi response later.

As long as openHAB does not support arrays/lists for items (would this be worth a feature request?), I think a semicolon separated String would be good enough.

The user can separate the string in a rule if necessary.
Or just use something like:

if ( Kodi_Genre.state.toString.contains("Comedy")) {
..
}

Yep - that is exactly how I was intending to use it.

Here is an example:

curl -su <USER>:<PASSWORD> -H "Content-type: application/json" -X POST -d '{"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":1,"properties":["genre"]},"id":1}' http://<IP>:8080/jsonrpc
{"id":1,"jsonrpc":"2.0","result":{"item":{"genre":["Crime","Drama","Suspense","Thriller"],"id":968,"label":"xxx.mov","type":"episode"}}}

Yes, I think it is worth to open an issue in ESH and discuss about such an Item. We already have a StringListType which is capable to wrap String data. And there already is a CallerItem which accepts or delivers such data. I can imagine introducing a ListItem to hold a list of Strings shouldn’t be a big deal.

In the meantime I will try to implement it like suggested.

Lets see where this is going.

I did my part. :grin:

I created a pull request. :wink:

https://github.com/openhab/openhab2-addons/pull/3631