OH2 and new Kodi Binding (org.openhab.binding.kodi not org.openhab.binding.xbmc)

Hey guys,

i run into some issues with the new org.openhab.binding.kodi and OH2. Alle the threads here are about the old xbmc binding, where the documentation is much more better and the syntax is quite different.

to use kodi with oh2 is just discovered it within the paperUI and with channels i can read the title and control kodi.

But now i want to use kodi in some rules and therefore i need to send commands directly to kodi. how can i do this?

my frist try:

items --> works to control kodi play/pause etc.

//Kodi
Player  Kodi_Control "Kodi Control" (Wohnzimmer){channel="kodi:kodi:e243d99b:control"}

now i want to use that in a rule:

items

//Multimediasteuerung
Switch Pause "Film anhalten" (Wohnzimmer)

rules

rule "Film anhalten"
	when Item Pause changed to ON
	
	then 
		Kodi_Control.sendCommand("pause")
	
end

can anyone explain how this should work?

thanks!

Change your rule to:

Kodi_Control.sendCommand("PAUSE")

and it should work, although I don’t understand why your use case needs a separate Switch item.

Thank you, its working! =)

i need the switch item and the rule to distinguish between several devices. So i can pause and openhab automatically knows which device to pause. i use this for alexa, so there is just one command i need to speak. here are my rule and item now:

item

//Multimediasteuerung
Switch Pause "Pausemodus" (Wohnzimmer) [ "Switchable" ]
Player  Kodi_Control "Kodi Control" (Wohnzimmer){channel="kodi:kodi:e243d99b:control"}

//Harmony
String Harmony_Activity "Current Activity [%s]"  (Wohnzimmer) { channel="harmonyhub:hub:HarmonyHub:currentActivity" }
Switch Harmony_skytv 	"Sky Fernseher" 	(Wohnzimmer) 	[ "Switchable" ]
Switch Harmony_skybeamer 	"Sky Beamer" 	(Wohnzimmer) 	[ "Switchable" ]
Switch Harmony_koditv 	"Kodi Fernseher" 	(Wohnzimmer) 	[ "Switchable" ]
Switch Harmony_kodibeamer 	"Kodi Beamer" 	(Wohnzimmer) 	[ "Switchable" ]
Switch Harmony_alles 	"alle Media Geräte" 	(Wohnzimmer) 	[ "Switchable" ]

rule

rule "Film anhalten"
	
	when Item Pause received command ON
	
	then
		
		if(Harmony_Activity.state == "KODI auf Fernseher" || Harmony_Activity.state == "KODI auf Beamer"){
		Kodi_Control.sendCommand("PAUSE")
		}
		else if(Harmony_Activity.state == "SKY auf Fernseher" || Harmony_Activity.state == "SKY auf Beamer"){
		sendHttpGetRequest("http://192.168.1.55/web/remotecontrol?command=164")
		}
	
end


rule "Film fortsetzen"
	when Item Pause received command OFF
	
	then 
		if(Harmony_Activity.state == "KODI auf Fernseher" || Harmony_Activity.state == "KODI auf Beamer"){
		Kodi_Control.sendCommand("PLAY")
		}
		else if(Harmony_Activity.state == "SKY auf Fernseher" || Harmony_Activity.state == "SKY auf Beamer"){
		sendHttpGetRequest("http://192.168.1.55/web/remotecontrol?command=164")
		}
end


if there is a better solution for that, then i am grateful for any ideas how to optimize the construct :wink:

I used to use Player.state as a trigger for lights - doesnt seem to be a state in Kodi binding now?

OK found this by playing:
Item:
Player Kodi_State “Kodi State [%s]” {channel=“kodi:kodi:GUID:control”}

SiteMap:
Text item=Kodi_State

However no STOP state!!!

Hi Andrew,

i’m struggling with the same thing
Kodi binding and dimmer rule

The Kodi binding has a separate channel/item for Stop

But i’m not able to trigger my lights when I pres the stop button