[SOLVED] Openhab ignoring rule

rules
items
Tags: #<Tag:0x00007f0147528cb8> #<Tag:0x00007f0147528b78>

(Jan Keber) #1

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

( ) #2
  • 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

(Rossko57) #3

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


(Thomas Bail) #4

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

Thomas


(Jan Keber) #5

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