[SOLVED] Kodi and Yamaha receiver rules

Hi. I’m trying to get my yamaha receiver change the hdmi input to kodi when I select a stream to run via openhab. Its weird that I can change the input with one rule that I’ve created and another rule to change the radio, but I can’t mix the rules.

// Yamaha Receiver
 
Switch Yamaha_Power			"Power [%s]"				{ yamahareceiver="uid=living, zone=main, bindingType=power" }
Dimmer Yamaha_Volume        "Volume [%.1f %%]"          { yamahareceiver="uid=living, zone=main, bindingType=volumePercent" }
Switch Yamaha_Mute          "Mute [%s]"                 { yamahareceiver="uid=living, zone=main, bindingType=mute" }
String Yamaha_Input         "Input [%s]"                { yamahareceiver="uid=living, zone=main, bindingType=input" } 
String Yamaha_Surround      "Surround [%s]"             { yamahareceiver="uid=living, zone=main, bindingType=surroundProgram" } 
Number Yamaha_NetRadio  	"Net Radio"					{ yamahareceiver="uid=living, zone=main, bindingType=netRadio" }
Number Yamaha_VolumeDb      "Volume [%.1f dB]"			{ yamahareceiver="uid=living,zone=main,bindingType=volumeDb" } 

// Kodi (Android Box)

String	Kodi_State			"Kodi State [%s]"		{ xbmc="<[#livingRoom|Player.State]" }
String	Kodi_Title			"Kodi Title [%s]"      	{ xbmc="<[#livingRoom|Player.Title]" }
String	Kodi_ShowTitle  	"Kodi Show [%s]"      	{ xbmc="<[#livingRoom|Player.ShowTitle]" }
Switch	Kodi_PlayPause  	"Kodi Play/Pause"     	{ xbmc=">[#livingRoom|Player.PlayPause]", autoupdate="false" }
Switch	Kodi_Stop       	"Kodi Stop"		        { xbmc=">[#livingRoom|Player.Stop]", autoupdate="false" }
String	Kodi_Notify     	"Kodi Notify [%s]"     	{ xbmc="<[#livingRoom|GUI.ShowNotification]", autoupdate="false" }
String	Kodi_Volume			"Kodi Volume"			{ xbmc="=[#livingRoom|Application.Volume]" }
Switch	Kodi_Radio        	"Kodi Start Radio"
String	Kodi_OpenMedia    	"Kodi Player file [%s]"	{ xbmc=">[#livingRoom|Player.Open]" }
Number	Stations			"Radio Stations"

And I use one selection box to select the radio station (stream).

Frame label="Radio Kodi"{
Selection item=Stations mappings=[0=OFF, 1=Band, 2=WDBO]
}

It works, when I select it plays the station, using this rule:

rule "Start Radio"

when
Item Stations changed
then
switch Stations.state {

	case 0:
		{
		sendCommand(Kodi_Stop, ON)
		}

	case 1:
		{
			if (Yamaha_Power.state == OFF)
			{
			sendCommand(Yamaha_Power,ON)
			sendCommand(Kodi_Stop, ON)
			sendCommand(Kodi_OpenMedia, "http://evp.mm.uol.com.br:1935/bnewsfm_sp/bnewsfm_sp/playlist.m3u8")
			}
			if (Yamaha_Power.state == ON)
			{
			sendCommand(Kodi_Stop, ON)
			sendCommand(Kodi_OpenMedia, "http://evp.mm.uol.com.br:1935/bnewsfm_sp/bnewsfm_sp/playlist.m3u8")
			}
		}

	case 2:
		{
			if (Yamaha_Power.state == OFF)
			{
			sendCommand(Yamaha_Power,ON)
			sendCommand(Kodi_Stop, ON)
			sendCommand(Kodi_OpenMedia, "http://oom-cmg.streamguys.com/orl965/orl965-tunein.mp3")
			}
			if (Yamaha_Power.state == ON)
			{
			sendCommand(Kodi_Stop, ON)
			sendCommand(Kodi_OpenMedia, "http://oom-cmg.streamguys.com/orl965/orl965-tunein.mp3")
			}
		}

	case 3:
		{
			if (Yamaha_Power.state == OFF)
			{
			sendCommand(Yamaha_Power,ON)
			sendCommand(Kodi_Stop, ON)
			sendCommand(Kodi_OpenMedia, "http://wbgl-sc.streamguys.us:80")
			}
			if (Yamaha_Power.state == ON)
			{
			sendCommand(Kodi_Stop, ON)
			sendCommand(Kodi_OpenMedia, "http://wbgl-sc.streamguys.us:80")
			}
		}

	case 4:
		{
			if (Yamaha_Power.state == OFF)
			{
			sendCommand(Yamaha_Power,ON)
			sendCommand(Kodi_Stop, ON)
			sendCommand(Kodi_OpenMedia, "http://stream.wucf.org:8000/jazz-128-aac.m3u")
			}
			if (Yamaha_Power.state == ON)
			{
			sendCommand(Kodi_Stop, ON)
			sendCommand(Kodi_OpenMedia, "http://stream.wucf.org:8000/jazz-128-aac.m3u")
			}
		}

	}	
end

The problem: I want to change the yamaha input to HDMI2. I can change the input using a selection and this rule:

Selection item=Yamaha_Input label="Entrada" mappings=[HDMI1="NET HDTV",HDMI2="Kodi",HDMI3="Chromecast","NET RADIO"="Internet Radio",TUNER="FM Radio"]
rule "Yamaha Listen FM Radio"
when
	Item Yamaha_Input changed to TUNER
then
	sendCommand(Yamaha_Power, ON)
	sendCommand(Yamaha_Volume, 40)
end

rule "Yamaha NetHD"
when
	Item Yamaha_Input changed to HDMI1
then
	sendCommand(Yamaha_Volume, 68)
end

rule "Yamaha Kodi"
when
	Item Yamaha_Input changed to HDMI2
then
	sendCommand(Yamaha_Volume, 58)
end

rule "Yamaha Chromecast"
when
	Item Yamaha_Input changed to HDMI3
then

	sendCommand(Yamaha_Volume, 58)
end

I want to add a command to the first rule to change the input.
I tried sendCommand(Yamaha_Input, HDMI2) without success.

case 1:
		{
			if (Yamaha_Power.state == OFF)
			{
			sendCommand(Yamaha_Power,ON)
                        sendCommand(Yamaha_Input,HDMI2)
			sendCommand(Kodi_Stop, ON)
			sendCommand(Kodi_OpenMedia, "http://evp.mm.uol.com.br:1935/bnewsfm_sp/bnewsfm_sp/playlist.m3u8")
			}
			if (Yamaha_Power.state == ON)
			{
                        sendCommand(Yamaha_Input,HDMI2)
			sendCommand(Kodi_Stop, ON)
			sendCommand(Kodi_OpenMedia, "http://evp.mm.uol.com.br:1935/bnewsfm_sp/bnewsfm_sp/playlist.m3u8")
			}

What I am doing wrong?
Thanks

Please try out

Yamaha_Input.sendCommand("HDMI2")

In general, the method is more reliable to work as expected than the action.
As HDMI2 is no regular state, I would try to send this as a string (the method should care about type conversion anyway).

It works just like you told. Thank you very much.

Sorry to revive this topic but I have another question.
I’ve been using kodi and my yamaha receiver out of box.

But I would like to know if there is one http command to send to my receiver that turns the tv on.
When I change the hdmi port via this binding and the tv is off, it automatically turns on. That’s very nice, its cec of course. The same happens when I turn off some hdmi equipment, the tv goes off.
But I wish I could have a command to turn on and turn off the tv. My tv is a lg but not those smarts and I don’t want to buy a IR receiver openhab compatible, just to power on/off the tv.

Is that possible?

1 Like

Did you ever figure out how to do this?

No, I didn’t.