[SOLVED] Openhab ignoring rule

Hi,

In my Modbus configuration i have 2 rules. Each rule changes value of a string depend if item value is 0 or 1.
One rule is working fine but the other one is ignored. Nothing happpens when item value is changed and there is no output in log:tail

Rules code:

rule "Status ventila ogr."
	when
		Item termostat1_prisotnost changed
	then
		if (termostat1_prisotnost == 1) {
			postUpdate(termostat1_prisotnost_p, "Odprt")
		}
		if (termostat1_prisotnost == 0) {
			postUpdate(termostat1_prisotnost_p, "Zaprt")
		}
end

rule "Okno kontakt"
	when 
		Item termostat1_status_okna changed
	then
		if (termostat1_status_okna.state == 1) {
			postUpdate(termostat1_status_okna_p, "Odprto")
		}
		if (termostat1_status_okna.state == 0) {
			postUpdate(termostat1_status_okna_p, "Zaprto")
		}
end
  • Do you see the item change in your events.log?
  • Add a logging line to both your rules
  • Restart openHAB to rule out other causes

One if() compares item.state (Good Thing), one if() compares just item (Bad Thing)

3 Likes

You said that the stae is a string, but you compare against a number so none of the if clauses will fire.

Thomas

Now i see… i’ve done such a stupid mistake. Thanks :slight_smile: