Open TV Channel in XBMC/Kodi

(Martin Herbst) #21

Not yet. Did not have the time to work on it. I also have a problem with the IPTV binding that I wanted to use for testing. Will try this weekend to create a test environment.

Template Example: Multimedia / Menu Navigation
(Michael1186) #22


you can manage PVR Channels with kodi JSON RPC functions …

Get PVR channel ID’s with a browser, use alltv or allradio:

http://your_kodi_ip:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "PVR.GetChannels", "params": {"channelgroupid": "alltv", "properties" :["uniqueid"]},"id": 1}

{"id":1,"jsonrpc":"2.0","result":{"channels":[{"channelid":564,"label":"ORF1 HD", ...

Test to open PVR channel ORF1 HD on kodi with a browser:


Convert the JSON RPC to use it with sendHttpGetRequest() at []

rule "ORF1 HD"
		Item kodi_orf1hd changed to ON
		var String json = "%7B%22id%22%3A1%2C%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22Player.Open%22%2C%22params%22%3A%7B%22item%22%3A%7B%22channelid%22%3A564%7D%7D%7D"
		sendHttpGetRequest("http://login:password@your_kodi_ip:8080/jsonrpc?request=" + json)
		sendCommand(kodi_orf1hd, OFF)

Manage music playlists with kodi addon functions …

String kodi_open_media            "Player Open Media"                 <kodi>                                    {xbmc=">[#kodi|Player.Open]"}
sendCommand(kodi_open_media, "special://profile/playlists/music/SmartPlaylist.xsp")

sendCommand(kodi_open_media, "special://profile/playlists/music/Playlist.m3u")

… and skip next/previous, play/pause with kodi JSON RPC functions



http://your_kodi_ip:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "Player.PlayPause", "params": { "playerid": 0 }, "id": 1}

rule "Skip Next"
		Item kodi_skip_next changed to ON
		var String json = "%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22Player.GoTo%22%2C%22id%22%3A1%2C%22params%22%3A%7B%22playerid%22%3A0%2C%22to%22%3A%22next%22%7D%7D"
		sendHttpGetRequest("http://kodi:kodi@" + json)
		sendCommand(kodi_skip_next, OFF)

rule "Skip Previous"
		Item kodi_skip_previous changed to ON
		var String json = "%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22Player.GoTo%22%2C%22id%22%3A1%2C%22params%22%3A%7B%22playerid%22%3A0%2C%22to%22%3A%22previous%22%7D%7D"
		sendHttpGetRequest("http://kodi:kodi@" + json)
		sendCommand(kodi_skip_previous, OFF)

rule "Play/Pause"
		Item kodi_play_pause changed to ON
        var String json = "%7B%22jsonrpc%22%3A+%222.0%22%2C+%22method%22%3A+%22Player.PlayPause%22%2C+%22params%22%3A+%7B+%22playerid%22%3A+0+%7D%2C+%22id%22%3A+1%7D"
		sendHttpGetRequest("http://kodi:kodi@" + json)
		sendCommand(kodi_play_pause, OFF)

Hope this helps some of you :wink:

Template Example: Multimedia / Menu Navigation
(Christoph Weitkamp) #23

Hi there,

I just opened a PR #2084 with an implementation for opening a PVR channel with an openhab item. Feel free to download the appended jar file in the comments of my last commit or build it on your own. I Like to hear some feedback.

Three points you need to know:

  1. Both new binding channels pvropentv and pvropenradio have a configuration for the PVR channel group which will be used to identifiy the PVR channel id from its name. The default configurations are “All channels” (in german Kodi systems you have to change them to “Alle Kanäle”).

  2. The items for the new binding channels pvropentv and pvropenradio should have the item type String. The accepted commands are the PVR channel names of your PVR configuration.

  3. I expect you to mention at least two known issues:
    a) First one is that there is no binding channel for the currently played PVR channel. In case of TV the value of the mediatype channel returns “channel” and the value of the title channel returns the currently played TV show. In case of radio the value of the mediatype channel returns “radio” and the value of the artist channel returns the name of the currently played radio channel. I am going to add that missing binding channel soon.
    b) Second one is that the values of all binding channels do not change if you are already watching a stream or listening to a stream and change the PVR channel over the new binding channels. By the way, the same situation appears if you change the played file over the binding channel playuri. I am going to look into that too.

Have fun while testing and report your experiences. Thanks.

(Christoph Weitkamp) #24

Hi there,

I have done a little research to solve the two mentioned issues.

a) I added a “pvrchannel” channel.

b) I assume this one could not be solved. If you are already watching a stream or listening to a stream and change the PVR channel the Kodi interface doesn’t send a notification over the JSON-RPC API which can be catched in the binding. Only solution I can imagine is to start an active polling job while waching or listening.

Have a good one.

(John Romani) #25

Dear Christoph
After spending tons of hours on trying to figure out how to use pvr-open-tv in openhab2, I am afraid documentation and discussions about it seem very limited on the internet. This post is the closest, and I am guessing you are the man behind this wonderful function. (JSON-solution seems too difficult for me).

All other items connected to the kodi-binding work fine (input, stop, systemcommand) - it’s just this one i can’t get my head around. My best guess it is not properly connected (between things and items) , but I am in a bit over my head.

I have setup as follows:
kodi:kodi:6ca9dab0-e269-455a-d695-80a9cf4fc1b3 [ipAddress=“”, port =“9090”]
Type pvropentv : pvr-open-tv [
group=“All channels”
String kodi_s_pvropen “PVR TV channel” { channel=“kodi:kodi:6ca9dab0-e269-455a-d695-80a9cf4fc1b3:pvr-open-tv” }

In the log
12:07:46.141 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘kody_s_pvropen’ received command HD: CNN HD
12:07:46.144 [INFO ] [marthome.event.ItemStateChangedEvent] - kody_s_pvropen changed from NULL to HD: CNN HD
but no channels switch…

Any pointing in a direction would be so appreciated, I don’t know what else to try or where to turn…

(Christoph Weitkamp) #26

Hi John,

I am trying to help where I can. First of all: your configuration looks correct (NOTE, please use code fences to format your posted code, 5th to 9th icons above the posting window, it makes the code much easier to read). To switch the PVR channel you have to send the exact PVR channel name to the kodi_s_pvropen item. In my example the exact PVR channel name is “(3) RTL”.

I configured my PVR client using a .m3u file:


#EXTINF:-1 tvg-id="" tvg-logo="rtl.png",(3) RTL


    kodi_s_pvropen.sendCommand("(3) RTL")


    Selection item=kodi_s_pvropen mappings=["(3) RTL"="RTL"]

(John Romani) #27

thank you so much for taking the time to look at my problem, I feel hopeful to get closer to a solution although I am afraid this time wasn’t it :wink:
The big difference was not having used rules as well, which I am not sure was a problem as the Item seemed to get trigged even before the rule (I was just inputting the channel name through PaperUI)

In any case I tried your advice, and even changed my channel name to match your example but with no luck - still no response once the Item receives the command.

PS. (I know it’s a bit confusing with sometimes naming my variables kody instead of kodi but I have double checked they are consistent).

Do you mind sharing an .item example aswell?

All the best


09:33:16.712 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'kody_s_pvropen' received command (3) RTL
09:33:16.717 [INFO ] [marthome.event.ItemStateChangedEvent] - kody_s_pvropen changed from US: CNN HD to (3) RTL
09:33:17.033 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'kody_s_pvropen' received command (3) RTL


rule "sodium-kodi-action"
Item kody_s_pvropen changed
 kody_s_pvropen.sendCommand("(3) RTL")


kodi:kodi:6ca9dab0-e269-455a-d695-80a9cf4fc1b3 [ipAddress=“”, port =“9090”]
Type pvropentv : pvr-open-tv [
group=“All channels”

(Christoph Weitkamp) #28

You are welcome. Can you please activate the DEBUG logging for the Kodi binding and try it again? I am interested in the complete log for this process. Maybe we have to dig a little deeper.

What PVR setup do you use in Kodi? Which addon? I use IPTV Simple Client. Do you configure any PVR channel groups? Do you use another third-party app to control your Kodi? Any remote control?

How do you setup your openHAB? Do you use PaperUI? Was the Kodi device discovered automatically after installing the binding? It maybe a problem to use a mixture of UI defined Things, Items and Channels in combination with manually defined ones. As I said the *.items file you posted is correct. So it is not necessary to post another example if it.

In PaperUI your Kodi Thing is shown in the “Configuration” -> “Things” section. If you click on it you see a subpage with all possible Channels for the Kodi Thing - be aware that the pvr-open-tv is advanced and you have to click “Show more” to see it. Behind the our-open-tv Channel is shown a pencil to access the Channel Configuration. I assume the default configuration “All channels” is used, because it is the default value. There maybe a problem with the localization you used in Kodi. E.g. I use a German setup of Kodi and the default PVR channel group it translated to “Alle Kanäle” instead of “All channels”. If you’re using Swedish you maybe must adopt the matching translation.

(John Romani) #29

Thanks again for taking the time and digging deeper. I also believe it might be some conflict between things discovered automatically and stored in a database and self-defined things from .things .

I have previously tried setting them up using paperUI but after this discussion removed the Kodi-thing and redfined in manually ONLY.

I use the default configuration in english on my kodi so “All channels” should be the correct group. I use IPTV Simple Client.

Also now here is a log from the debug…

17:53:08.719 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'kodi_s_pvropen' received command US: CNN HD
17:53:08.721 [DEBUG] [hab.binding.kodi.handler.KodiHandler] - Received unknown channel pvr-open-tv
17:53:09.747 [DEBUG] [i.internal.protocol.KodiClientSocket] - send message: {"jsonrpc":"2.0","id":32,"method":"Application.GetProperties","params":{"properties":["version","name"]}}

(John Romani) #30

update… since I wrote last time I uninstalled openhab all together and reinstalled it creating items and things manually only.
It still doesn’t work for pvr-open-tv yet all other kodi commands seem to work.
Interestingly this error is new in my log when I start up the openhab server:

19:09:03.819 [ERROR] [.thing.internal.GenericThingProvider] - Channel type kodi:pvropentv could not be resolved.

(Christoph Weitkamp) #31

Which OH2 version do you use? I currently assume your version doesn’t support the PVR channels, yet.

(John Romani) #32

version 2.0.0-3, the latest one for Qnap… if it is not supported there, is there a way to update/replace some file to enable that support?

(Christoph Weitkamp) #33

You can download a newer binding version here: . But I cannot guarantee that it works.

For installation follow this documentation. Be aware to remove the old binding version first.

(John Romani) #34

I did, I really tried but I am afraid that was a level or two out of my league (I did get an official 2.1 version to work, but that also seemed to lack support for pvropentv.
I will just have to wait for a new version to be released for Qnap which judging by this info seems near.

Once again, I want to thank for all the help you have given me, and that I finally at least understand what seems to be the problem. I might ask you again once the new version is released :wink:

Thank you

(Christoph Weitkamp) #35

Alright, let’s hope you don’t have to wait too long. Don’t hesitate to ask again if you need further help.

(Sebastian) #36

Hi all,

I’m also struggeling with the PVR channel for the Kodi binding.

Same error here with 2.1.0 stable release.

My config looks like this

Thing kodi:kodi:wz "Kodi" @ "Wohnzimmer" [ ipAddress="", port="9090" ] {
        Type pvropentv : pvr-open-tv [
            group="Alle Kanäle"
String KodiWzPvrOpenTv  "PVR TV Kanal" { channel="kodi:kodi:wz:pvr-open-tv" }

Any hints?


(Christoph Weitkamp) #37

Hey Sebastian,

I maybe detected a syntax error in the documentation. Could you please try this:

Thing kodi:kodi:wz "Kodi" @ "Wohnzimmer" [ipAddress="", port="9090"] {
        Type pvr-open-tv : pvr-open-tv [
            group="Alle Kanäle"

(Dieter) #38

Hey Christoph,

Thank you a lot for this solution :smiley:

Lately I was playing with Openhab 2 to get things up and running and I had exactly the same issue using the pvr-open-tv option.

The solution is, as you mentioned, the type in the things configuration. It works as a charm after changing 'Type pvrsopentv : pvr-open-tv [" to “Type pvr-open-tv : pvr-open-tv [”.

I don’t know who’s responsible for the openhanded add on doc but maybe someone can change that! The link:

Thanks again for the great help.

(Sebastian) #39

Hi Christoph,

I somehow missed your answer last week, sorry.
Just gave your proposal a try and it works fine.
Thanks for the hint.

(Christoph Weitkamp) #40

@dloss @hannibal29 You are welcome. I am glad you got it working.

I already take care of updating the documentation: