XBMC Binding Problem

Hi,

I have a problem getting the xbmc binding to work - I hope somebody can help.

I am using the 1.8.1 versions of the binding and action jars and am running kodi 15.2 which is, I believe, correctly set up for remote web access - at least I can access it OK using android apps and Chorus.

The relevant parts of my cfg, items and log files are given below.

openhab.cfg

xbmc:livingRoom.host=192.168.1.66
xbmc:livingRoom.rsPort=8080
xbmc:livingRoom.wsPort=9090
xbmc:livingRoom.username=kodi

openhab.items

Group kodi (All)
String Artist “Artist [%s]” (kodi) {xbmc="<[#livingRoom|Player.Title]"}

Relevant lines from log file

08:27:48.327 [DEBUG] [b.x.internal.XbmcActiveBinding:54 ] - XBMC Refresh Service activate()
08:27:48.331 [DEBUG] [b.x.internal.XbmcActiveBinding:390 ] - XBMC Refresh Service updated()
08:27:48.344 [DEBUG] [b.x.internal.XbmcActiveBinding:233 ] - Creating new XbmcConnector for ‘#livingRoom’ on 192.168.1.66
08:27:50.615 [ERROR] [binding.xbmc.rpc.XbmcConnector:208 ] - [192.168.1.66]: Websocket error: invalid version format: GET
08:27:50.618 [ERROR] [b.x.internal.XbmcActiveBinding:242 ] - Connection failed for ‘#livingRoom’ on 192.168.1.66
08:28:48.333 [DEBUG] [b.x.internal.XbmcActiveBinding:265 ] - Broken connection found for ‘#livingRoom’, attempting to reconnect

08:28:48.454 [ERROR] [binding.xbmc.rpc.XbmcConnector:208 ] - [192.168.1.66]: Websocket error: invalid version format: GET
08:28:48.459 [DEBUG] [b.x.internal.XbmcActiveBinding:271 ] - Reconnect failed for ‘#livingRoom’, will retry in 60s
08:29:48.461 [DEBUG] [b.x.internal.XbmcActiveBinding:265 ] - Broken connection found for ‘#livingRoom’, attempting to reconnect

08:29:48.766 [ERROR] [binding.xbmc.rpc.XbmcConnector:208 ] - [192.168.1.66]: Websocket error: invalid version format: GET
08:29:48.768 [DEBUG] [b.x.internal.XbmcActiveBinding:271 ] - Reconnect failed for ‘#livingRoom’, will retry in 60s


You see I get a repeated error saying

Websocket error : invalid version format : GET

Other folks seem to have this working and so I doubt that it is a version problem. Anybody got any ideas?

Thanks

Just to check, you do have the both the binding and action files added?

org.openhab.action.xbmc-1.8.1.jar
org.openhab.binding.xbmc-1.8.1.jar

and still checking, but you do have something playing on Kodi when you test your settings?

the Player.Title property is checked every 60 seconds and I think that is what you are seeing.

Can you control Kodi with openHAB?

Maybe try and get that working first to make sure you are connected.

I didn’t like the polling nature of the current binding as it was clogging up my log file with Kodi wasn’t online.

I use https://github.com/KenV99/service.xbmc.callbacks2

It allows you to assign scripts or calls to many of the Kodi events, I send from Kodi to openhab

http://raspberrypi.local:8080/CMD?Kodi_Received_State=Shutdown

with a single item Kodi_Received_State that gets up dated with whatever Kodi sends it. Then I have rule that process that information within OpenHAB.

I assume you don’t have openHAB and Kodi on the same machine? If you do then you would need to change the port from 8080 in Kodi as well.

Hope that helps. Good luck

Hi Sam,

Thanks for the quick reply. Yes I have added both jars - and have some music playing on kodi. Cannot control kodi either - have tried other properties but all give the same version GET error.

I agree with you that a kodi addon is probably a better way to go and will remove unnecessary polling. There are a few possibilities in this regard but “MQTT Adapter” appeals the most because the MQTT binding in OpenHAB seems very robust


I will struggle with the xbmc binding for a bit longer and then give “MQTT Adapter” a trial run.

Thanks for your help.

In addition to enabling the Web UI under Settings > Web server, make sure you have also enabled the option for ‘allow remote control by programs on other systems’ which is under ‘Remote control’. This is needed for the JSON RPC API! And be certain you do not have any other services using the same ports on the same machine as @sam suggested.

While I have this working with 3 KODI instances, the binding is somewhat broken. Many items do not update as they should, and it seems that the KODI API has changed quite a lot since this XBMC Binding was last updated.

The main reason I still use this binding is to auto-kill the lights when a movie starts playing, and dim them up on pause/stop.

Best regards,
.

I really like that script.xbmc.callbacks2 addon

It is very simple but very flexible and lets you call all type of scripts. If you do intend to use it, once installed edit the settings.xml file in the userdata folder rather than trying to wrestle with the Kodi interface.

One item in openHAB gets sent updates on events, though you can obviously have more. I also have a `Cinema_Switch’ because I only really want the lights to auto dim when using the projector rather than the tv.

// settings.xml
<setting id="onPlaybackPaused_str.htp" value="http://raspberrypi.local:8080/CMD?Kodi_Received_State=PlaybackPaused" />
<setting id="onPlaybackResumed_str.htp" value="http://raspberrypi.local:8080/CMD?Kodi_Received_State=PlaybackResumed" />
<setting id="onPlaybackStarted_str.htp" value="http://raspberrypi.local:8080/CMD?Kodi_Received_State=PlaybackStarted" />
<setting id="onPlaybackStopped_str.htp" value="http://raspberrypi.local:8080/CMD?Kodi_Received_State=PlaybackStopped" />
<setting id="onProfileChange_str.htp" value="http://raspberrypi.local:8080/CMD?Kodi_Received_State=ProfileChange" />
// items
Switch	Cinema_Mode	
String  Kodi_Received_State  "State [%s]"  

// rule

rule "Dimm lights based on Kodi state"
when
    Item Kodi_Received_State changed
then
  var String Kodistate = Kodi_Received_State.state.toString()
  if(Cinema_Mode.state==ON){
    if (Kodistate == "PlaybackStarted" || Kodistate == "PlaybackResumed") {
      sendCommand(gsLoungeLights, OFF)
    }

    if (Kodistate == "PlaybackStopped" || Kodistate == "PlaybackPaused") {
      sendCommand(gsLoungeLights, ON)
    }
  }
end



1 Like

Nice! Here is how I do it (ATM), for reference, with the XBMC Binding (similar rules for each room):

rule "Adjust Living lighting when XBMC starts/stops"
when
Item XbmcLiving_Player changed
then
var String state = XbmcLiving_Player.state.toString()

logInfo("XBMC State:", state.toString)
switch (state.lowerCase) {
  case "play" :  {
  	   		sendCommand(Light_GF_Living_Floor, OFF)
  	   		sendCommand(Light_GF_Living_Iris, OFF)
  	   		sendCommand(Light_GF_Living_Strip, OFF)
  			 }
  case "pause" : {
  	   		sendCommand(Light_GF_Living_Floor, ON)
  	   		sendCommand(Light_GF_Living_Iris, ON)
  	   		sendCommand(Light_GF_Living_Strip, ON)
  }
  case "stop"  : {
  	   		sendCommand(Light_GF_Living_Floor, ON)
  	   		sendCommand(Light_GF_Living_Iris, ON)
  	   		sendCommand(Light_GF_Living_Strip, ON)
  }

}
end

Thanks for your input Mike. I never did get the xbmc binding to work on my system and your comments about it being broken made me give up on it.

Happily I can report that the kodi addon called “MQTT Adapter” works right out of the box and it is simple to subscribe to the topics from within OpenHAB.

I will take a look at the callback script recommended by Sam but I think I am happy with MQTT Adapter for now.

Thanks both.

Now this mqtt for kodi I have to try, what isthe latency like? The xbmc addon seems delayed by 2 secs for me, so very hard to work a volume control
Cheers for the insight guys.

Hi Chris,

I believe that MQTT Adapter (the kodi addon I am using) does not currently provide volume information in any of its published topics so could not be used for any form of volume control. Generally speaking, latency on my system is about a second (using a RPI as MQTT broker) which is just fine for switching lights and so forth.

N
From: chrishiscox
Sent: 09 February, 2016 3:57 AM
To: namirda@hotmail.com
Subject: [openHAB] [Add-ons/Bindings] XBMC Binding Problem

    chrishiscox
  February 8
  Now this mqtt for kodi I have to try, what isthe latency like? The xbmc addon seems delayed by 2 secs for me, so very hard to work a volume control
  Cheers for the insight guys.

Visit Topic or reply to this email to respond.