I’m running following configuration as bellow and can’t solve Rule issue.
I’ve an item: String Wilgotnosc "Wilgotnosc" <humidity> {channel="mqtt:topic:sprinkler:GPIO16"}
It gets values 0 or 1 in log file.
The second item used is switch: Switch SprinklerSystemSchedule "Zaplanowane podlewanie" <calendar>
rule "Sprinkler System Schedule"
when
Time cron "0 51 20 1/1 * ? *"
then
if(SprinklerSystemSchedule.state == ON && Wilgotnosc == 0)
{
sendBroadcastNotification("SYSTEM NAWADNIANIA: Zaplanowane podlewanie AKTYWNE")
}
end
I want the rule to work only when both IF conditions for items are met. I can’t get this to work when I add ‘Wilgotnosc’ item. Seems OH doesn’t recognize the value/state of string item
I suspect that the issue is that the character “0” in the string item is not equal to the numeric zero in the IF statement. You could try changing the String item to a number, or change the numeric zero in the IF statement to a character zero (“0”).
But I have to wonder why Wilgotnosc isn’t a Switch item, and the IF statement would specify “== ON”.
If you wanted you could use a Switch Channel instead of a String Channel, and link that to a Switch Item. Then you just test for ON or OFF in your rules.
You will need to ensure that the Channel understands 1/0 is ON/OFF, which if you used a Things file requires just on=1, off=0 in your Channel configuration.