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.
Hy,
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:
http://your_kodi_ip:8080/jsonrpc?request={"id":1,"jsonrpc":"2.0","method":"Player.Open","params":{"item":{"channelid":564}}}
Convert the JSON RPC to use it with sendHttpGetRequest() at [http://www.freeformatter.com/url-encoder.html]
rule "ORF1 HD"
when
Item kodi_orf1hd changed to ON
then
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)
end
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.GoTo","id":1,"params":{"playerid":0,"to":"next"}}
http://your_kodi_ip:8080/jsonrpc?request={"jsonrpc":"2.0","method":"Player.GoTo","id":1,"params":{"playerid":0,"to":"previous"}}
http://your_kodi_ip:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "Player.PlayPause", "params": { "playerid": 0 }, "id": 1}
rule "Skip Next"
when
Item kodi_skip_next changed to ON
then
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@192.168.0.101:8080/jsonrpc?request=" + json)
sendCommand(kodi_skip_next, OFF)
end
rule "Skip Previous"
when
Item kodi_skip_previous changed to ON
then
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@192.168.0.101:8080/jsonrpc?request=" + json)
sendCommand(kodi_skip_previous, OFF)
end
rule "Play/Pause"
when
Item kodi_play_pause changed to ON
then
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@192.168.0.101:8080/jsonrpc?request=" + json)
sendCommand(kodi_play_pause, OFF)
end
Hope this helps some of you
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:
-
Both new binding channels
pvropentv
andpvropenradio
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â). -
The items for the new binding channels
pvropentv
andpvropenradio
should have the item typeString
. The accepted commands are the PVR channel names of your PVR configuration. -
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 themediatype
channel returns âchannelâ and the value of thetitle
channel returns the currently played TV show. In case of radio the value of themediatype
channel returns âradioâ and the value of theartist
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 channelplayuri
. I am going to look into that too.
Have fun while testing and report your experiences. Thanks.
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.
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.things:
kodi:kodi:6ca9dab0-e269-455a-d695-80a9cf4fc1b3 [ipAddress=â192.168.0.210â, port =â9090â]
{
Channels:
Type pvropentv : pvr-open-tv [
group=âAll channelsâ
]
}
kodi.items:
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âŠ
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:
demo.m3u
#EXTINF:-1 tvg-id="RTL.de" tvg-logo="rtl.png",(3) RTL
rtp://@239.35.20.10:10000
demo.rule:
kodi_s_pvropen.sendCommand("(3) RTL")
demo.sitemap:
Selection item=kodi_s_pvropen mappings=["(3) RTL"="RTL"]
Cristoph,
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
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
Log
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
Rules
rule "sodium-kodi-action" when Item kody_s_pvropen changed then kody_s_pvropen.sendCommand("(3) RTL") end
Things
kodi:kodi:6ca9dab0-e269-455a-d695-80a9cf4fc1b3 [ipAddress=â192.168.0.210â, port =â9090â]
{
Channels:
Type pvropentv : pvr-open-tv [
group=âAll channelsâ
]
}
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.
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"]}}
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.
Which OH2 version do you use? I currently assume your version doesnât support the PVR channels, yet.
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?
You can download a newer binding version here: https://openhab.jfrog.io/openhab/libs-pullrequest-local/org/openhab/binding/org.openhab.binding.kodi/ . But I cannot guarantee that it works.
For installation follow this documentation. Be aware to remove the old binding version first.
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. https://github.com/openhab/openhab-qnap-qpkg/issues/33
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
Thank you
Alright, letâs hope you donât have to wait too long. Donât hesitate to ask again if you need further help.
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="xxx.xxx.xxx.xxx", port="9090" ] {
Channels:
Type pvropentv : pvr-open-tv [
group="Alle KanÀle"
]
}
String KodiWzPvrOpenTv "PVR TV Kanal" { channel="kodi:kodi:wz:pvr-open-tv" }
Any hints?
Thanks,
Sebastian
Hey Sebastian,
I maybe detected a syntax error in the documentation. Could you please try this:
Thing kodi:kodi:wz "Kodi" @ "Wohnzimmer" [ipAddress="xxx.xxx.xxx.xxx", port="9090"] {
Channels:
Type pvr-open-tv : pvr-open-tv [
group="Alle KanÀle"
]
}
Hey Christoph,
Thank you a lot for this solution
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: http://docs.openhab.org/addons/bindings/kodi/readme.html
Thanks again for the great help.
Hi Christoph,
I somehow missed your answer last week, sorry.
Just gave your proposal a try and it works fine.
Thanks for the hint.
@dloss @hannibal29 You are welcome. I am glad you got it working.
I already take care of updating the documentation: