[SOLVED] String equals not working. What am i'm doing wrong?

I’ve created two wtring items:

String Str_Secur_Panel1 {expire="1s,state=NULL" }
String Str_Secur_AlarmState

This is my rule:

rule “Activate Alarm”
when
Item Str_Secur_Panel1 changed
then
if( Str_Secur_Panel1.state == 999 ) {
Str_Secur_AlarmState.sendCommand(8)
}
end

“999” perhaps?

Thats it! Thanks!

Okay. You understand why - rules sees 999 as a number, nine hundred and ninety-nine. “999” is a string, three 9 characters. Apples and oranges.

That Item is also a string item so needs to be:

Str_Secur_AlarmState.sendCommand("8")
1 Like

I’m not sure about that, because openHAB should use (8).toString automatically.

Yes, you’re absolutely right in this example - but only because the string is a numerical value.

Yepp, true.