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"
Item IHC_10_2 received update ON
if(Item IHC_12_7==ON) {
voice(“The light is turned on”)

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:

voice(“The light is turned on”)

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.


Thanks - that works.