Open TV Channel in XBMC/Kodi


(Smhgit) #41

Hi,

I have added the Kodi binding but I am not sure how I can use it … :frowning:

I see the kodi, I can send commands as mute and volume. Now I am trying to play TV. The thing is that the TV channels are coming from videos and not from the pvr (Videos -> Video add-ons -> add on …).

How can I select item from Videos? SHould I use the playuri and give it the path to the video?

Thx


(Christoph Weitkamp) #42

Hi,

I’m afraid that is not possible right now.

It depends. If you don’t use PVR the binding cannot play a file from your Kodi database directly. It’s “stupid” and doesn’t know anything about it. You can use the playuri channel for your purpose but you have to know the exact path to the file or add-on you want to play.

E.g. playing a YouTube video is possible - requires YouTube add-on installed.

myKodi_playuri.sendCommand("plugin://plugin.video.youtube/?action=play_video&videoid=YOUTUBE_VIDEO_ID")

If it helps I can implement a new feature to play a favorite.


(Smhgit) #43

@cweitkamp

Thx for your reply!

I found out that the in the end that actually the add-on plays a stream and not a file. I was able to find out the stream path (http://…m3u8) so using that URL I was able to send playUri command to Kodi via OpenHab and it worked.

My issue is that it is very difficult (at least I don’t know easy way to do it) to extract the streaming url. I have 4 channels and until now I was able only to find 2. So maybe favorites can help here. If I can add the channel to favorite, give it s simple short name and just use this name for playing, it will be great.

Thx


(Christoph Weitkamp) #44

Sounds good. You’re welcome.

I will put the implementation of the feature to handle favorites with the Kodi binding onto my To-do list.

In the meantime you can try the following steps to find out the stream URLs. I don’t know how you control your Kodi, but there is a very good APP called Yatse: Kodi Remote. You can add your TV channels to your favorites and sync them with the APP. Inside the APP the full path to every favorite link is shown underneath its name. Most of the time these paths can be opened with the playuri channel.


(Smhgit) #45

@cweitkamp

Thx, will try today and update


(Christoph Weitkamp) #46

I submitted a first try.


(Sasha) #47

Hi Team,

Any ides how can I start the Plex addon from openhab kodi or http binding?

It’s openning fine from yatse remote, but not showing the URI for it.
Even tried to sniff with Wireshark but no proper result…

Would be very grateful for help!


(Scott Rushworth) #48

The Kodi binding may be able to do this, but I call the Kodi API directly to launch addons, Here is a rule where I am calling the Kodi API to launch a custom addon that I use for multiline notifications. Buried in there you may find a hint for how to launch the Plex addon. This rule also is used for smaller Kodi notifications, which the binding can do but I like to add the icon.

import java.lang.StringBuilder
import java.util.List

rule "Alert: Kodi Notification"
when
    Item Kodi_Notification received command
then
    if ((Outlet6.state == ON && DS_FamilyRoom_Kodi_SystemState.state == ON) || (Outlet2.state == ON && US_MasterBedroom_Kodi_SystemState.state == ON)) {
        //logDebug("Rules", "Alert: Kodi notification: starting")
        if (receivedCommand.toString.contains("Time: ")) {
            val List<String> statusAlertListOriginal = receivedCommand.toString.replace(".","").replace(",","%2C").split("\n")
            var List<String> statusAlertList = newArrayList
            for (var index = 0 ; index < statusAlertListOriginal.size ; index++) {
                val String item = statusAlertListOriginal.get(index)
                if (item != "") {
                    statusAlertList.add(item)
                }
                else {
                    statusAlertList.add("%20")
                }
            }
            //logDebug("Rules", "Alert: Kodi notification statusAlertList.size=[{}]",statusAlertList.size)
            while (statusAlertList.size < 23) {
                //logDebug("Rules", "Alert: Kodi notification: finding blanks")
                statusAlertList.add("%20")
            }
            //logDebug("Rules", "Alert: Kodi notification statusAlertList.size=[{}]",statusAlertList.size)
            val StringBuilder kodiAlertString = new StringBuilder
            kodiAlertString.append("{\\\"jsonrpc\\\":\\\"2.0\\\",\\\"id\\\":1,\\\"method\\\":\\\"Addons.ExecuteAddon\\\",\\\"params\\\":{\\\"addonid\\\":\\\"script.module.extendednotifications\\\",\\\"params\\\":{\\\"title\\\":\\\"openHAB\\\",")
            for (var index = 0 ; index < statusAlertList.size ; index++) {
                kodiAlertString.append("\\\"line")
                kodiAlertString.append(index + 1)
                kodiAlertString.append("\\\":\\\"")
                kodiAlertString.append(statusAlertList.get(index))
                kodiAlertString.append("\\\"")
                if (index != statusAlertList.size - 1) {
                    kodiAlertString.append(",")
                }
            }
            kodiAlertString.append("}}}")
            if (Outlet6.state == ON && DS_FamilyRoom_Kodi_SystemState.state == ON) {
                executeCommandLine("/bin/sh@@-c@@/usr/bin/curl -s -X POST -H \"Content-Type: application/json\" -d \"" + kodiAlertString.toString + "\" \"http://<familyroomkodiip>:8080/jsonrpc?request=\"",5000)
            }
            if (Outlet2.state == ON && US_MasterBedroom_Kodi_SystemState.state == ON) {
                executeCommandLine("/bin/sh@@-c@@/usr/bin/curl -s -X POST -H \"Content-Type: application/json\" -d \"" + kodiAlertString.toString + "\" \"http://<bedroomkodiip>:8080/jsonrpc?request=\"",5000)
            }
        }
        else {
            if (Outlet6.state == ON && DS_FamilyRoom_Kodi_SystemState.state == ON) {
                executeCommandLine("/bin/sh@@-c@@/usr/bin/curl -s -X POST -H \"Content-Type: application/json\" -d \"{\\\"id\\\":1,\\\"jsonrpc\\\":\\\"2.0\\\",\\\"method\\\":\\\"GUI.ShowNotification\\\",\\\"params\\\":{\\\"image\\\":\\\"http://<ohserverip>:8080/static/favicon.ico\\\",\\\"title\\\":\\\"openHAB\\\",\\\"message\\\":\\\"" + receivedCommand.toString + "\\\"}}\" \"http://<familyroomkodiip>:8080/jsonrpc?request=\"",5000)
            }
            if (Outlet2.state == ON && US_MasterBedroom_Kodi_SystemState.state == ON) {
                executeCommandLine("/bin/sh@@-c@@/usr/bin/curl -s -X POST -H \"Content-Type: application/json\" -d \"{\\\"id\\\":1,\\\"jsonrpc\\\":\\\"2.0\\\",\\\"method\\\":\\\"GUI.ShowNotification\\\",\\\"params\\\":{\\\"image\\\":\\\"http://<ohserverip>:8080/static/favicon.ico\\\",\\\"title\\\":\\\"openHAB\\\",\\\"message\\\":\\\"" + receivedCommand.toString + "\\\"}}\" \"http://<bedroomkodiip>:8080/jsonrpc?request=\"",5000)
            }
        }
    }
end

(Sasha) #49

Got it working with a help of wireshark.

Here is a rule, in case someone needs it

rule "Start Plex addon on Kodi"
	when Item VT_kodi_start_plex received command ON
    then
		val String MY_URL = 'http://server-ip-address/jsonrpc?'
		var String myData = '{"jsonrpc":"2.0","method":"Files.GetDirectory","id":"1524370391046","params":{"directory":"plugin://script.plex/","media":"video","properties":["title","file","mimetype","thumbnail","dateadded"],"sort":{"method":"none","order":"ascending"}}}'

		sendHttpPostRequest(MY_URL, "application/json", myData)
end