Set a source on an Onkyo Receiver doesn't work?

Tags: #<Tag:0x00007fe7305c2e88>

Hey guys,

Total newb here. I’m preparing my environment ready for an Amazon Echo. I’ve decided to utilize OpenHAB and the Amazon HA Bridge to control my Onkyo stereo system from my Amazon Echo. My Onkyo has a Zone 2. I wanted to come up with a switch that toggles between two sources on my Zone Two. To that end, I created an Onkyo Switch Item. For some reason, however, I can’t get it to activate correctly. All the examples in the Wiki use the Number item for switching through sources, but I don’t believe I can use numbered items with the Amazon-HA Bridge. My item looks like this
Switch onkyoZ2Apple "AppleTV On {onkyo="INIT:hometheater:ZONE2_SOURCE_QUERY, ON:hometheater:ZONE2_SOURCE_GAME, OFF:hometheater:ZONE2_SOURCE_PC}

When I issue the switch using
http://192.168.1.100:8080/CMD?onkyoZ2Apple=ON

Nothing happens. Has anyone had luck directly selecting a particular source? A lot of people suggest setting up a rule, but I don’t even know what my rule would be in this situation.

Thanks

First of all, if you use example items from Onkyo wiki page, are you able to control Onkyo receiver from the openHAB? If yes, then at least you have configured Onkyo binding correctly. Secondly, you have type mismatch on your item (you miss apostrophe).

Anyhow switch item most probably is not best idea try to use with source. For switch item, Onkyo binding response parser interpret all values bigger than zero to ON and zero value to OFF (both GAME and PC sources are bigger than zero). You could use number item, then create virtual switch item and control source from the rule.

So some thing like this (not tested):

Number onkyoZ2Source “Source” {onkyo=“INIT:hometheater:ZONE2_SOURCE_QUERY, INCREASE:hometheater:ZONE2_SOURCE_UP, DECREASE:hometheater:ZONE2_SOURCE_DOWN, *:hometheater:ZONE2_SOURCE_SET”}

Switch onkyoZ2Apple “AppleTV On”

rule "control source"
	when Item onkyoZ2Apple received command
	then
		if (onkyoZ2Apple.state == ON) {
			onkyoZ2Source.sendCommand(2) // change 2 to correct source number if 2 is not correct
		} else {
			onkyoZ2Source.sendCommand(5) // change 5 to correct source number if 5 is not correct
		}
	end

I figured it out. I ended up making proxy items that then triggered a rule. I could then successfully switch the source inside the rule.