sendCommand as String

Hi guys

I am trying to update a String Item with a rule but nothing happens.
How do i need to update a String item with in my case “TUNER” i’m using the Yamaha binding.

rule Radio_TurnOn

when 
	Item Yahama_Radio changed from OFF to ON
then
    Yamaha_Input.sendCommand(new String("TUNER"))   // <-- does not work
	//Yamaha_Input.sendCommand("TUNER")				// <-- does not work

end

Put in some debugging to make sure your rule is actually being triggered. The second option you have looks correct. And check your events log to make sure it actually isn’t.

It may help if you posted more info: how do you define “Tuner” and “Yamaha_Input” and what do you actually want the tuner to do, what is the version and on what system do you run it.
The command you posted will just send the literal string “Tuner” to an item that you presumably configured called “Yamaha_Input”, which is probably not what you want. In addition, you may need some quotation marks to make it read rule "Radio_TurnOn"
What would help is if you describe what you want to do and then post all info regarding Items (and potentially Things)
I don’t own any Yamaha equipment and hence are not using the binding, but from a quick look a the docs: http://docs.openhab.org/addons/bindings/yamahareceiver/readme.html I am not sure that the simple text string “Tuner” means anything to the binding/Thing.

Thanks for the quick answers.

My Items are:

String Yamaha_Input         "Receiver Input [%s]"       (g_EG_Wohnzimmer)       {channel="yamahareceiver:yamahaAV:9ab0c000_f668_11de_9976_00a0def9859c:input"}
Switch Yamaha_Radio			"Yamaha Radio"              (g_EG_Wohnzimmer)		{knx="2/6/1"}

My other Rules in the same file do work as expected:

rule "Radio_ON"
when
	Item Yamaha_Input changed to TUNER
then
	Yamaha_Radio.postUpdate(ON)
end

rule "Radio_off"
when
	Item Yamaha_Input changed from TUNER
then
	Yamaha_Radio.postUpdate(OFF)
end

So with the switch i want to set the receiver to TUNER, what it also should reflect the state if turn the tuner input on the device itself to Tuner.

Yamaha_Input.postUpdate(“TUNER”)

This updates the OpenHAB string item, but will not send it to the real device.

Your item is configured differently than the example Input item in the documentation:

String    Yamaha_Input    "Input [%s]"    <video>    { channel="yamahareceiver:zone:9ab0c000_f668_11de_9976_00a0ded41bb7:Main_Zone:zone_channels#input" }

You may want to look at the Thing in PaperUI to double check the channel configuration.

@saperlot Just having had a quick look at the docs, it appears that the command in your first post should read:

Yamaha_Input.sendCommand(TUNER)

(Note the absence of quotation marks.)

My item does work well, There is maybe different channel naming if multiple zones are activated.

i do also have a selection in a sitemap by which i can successfully switch between the inputs.

Selection item=Yamaha_Input mappings=[HDMI1="SwisscomTV",HDMI2="Kodi",NET_RADIO="NetRadio",TUNER="Radio"]

But nothing seems to work in the rule. Also not that which @lipp_markus suggested without the string.

So far, thanks for all the inputs.

posting the string TUNER to the rest API over the openhab web interface also works as expected.
So that still makes me wonder why my rule does not work.

I suggest you add some logging to the beginning of your rule to make sure that it is actually triggering. If it is not triggering, then I would modify the rule like this:

rule Radio_TurnOn
when 
	Item Yahama_Radio changed
then
	if (Yahama_Radio.state == ON && Yahama_Radio.previousState.state == OFF) {
        Yamaha_Input.sendCommand("TUNER")
    }
end

Guys, i am so sorry. :flushed: It is always being a stupid error if you can not find a solution after 2 hours of trial and error.
Yamaha and Yahama is not the same, even if its sounds similar :frowning:

The Designer can help identify issues like this. Glad you got it working!

I did using it. unfortunately it does not find such errors