IF sentences in RULE

I use OpenHab 1.8.3 to run my IHC. I have a big number of switches one of them is called:

Switch IHC_10_2 “Light” (IHC, GK) {ihc=“27739”}

Another one is called:

Switch IHC_12_7 “Control LED” (IHC, GK) {ihc=“56847”}

Then I will like to make a rule saying:

When the light is turned ON,
Then say”The lights is turn on” if the control LED is ON.

My rule code look like this:

rule "Office light"
when
Item IHC_10_2 received update ON
then
if(Item IHC_12_7==ON) {
voice(“The light is turned on”)
}
End

It work perfect without the IF sentence. The voice sentence works alone. Question - How can I make the condition; The “voice” shall only be active when the Control LED is set.

This is important to me in order to improve the WAF (wife acceptance factor)

I’m no rule expert but here is my observation.

In the if part, remove the word “Item” and add ".state"so it reads:

if(IHC_12_7.state==ON){
voice(“The light is turned on”)
}
End

Also, I often refer to this page when trying to figure out new rules. Often you can use one of the examples to adapt you your situation.

https://github.com/openhab/openhab1-addons/wiki/Samples-Rules

Thanks - that works.