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.
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.
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. 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