Your first attempt will not work. You can’t do math or comparisons in the rule triggers.
Your second attempt is going to be the way to implement this. I’ve not actually tried to do a comparison to a number state but the " " give me pause. Does it work if you remove the quotes around 4?
The second attempt seems to work, even with the "" .
The issue seems to be the trigger. In this case it could happen that the trigger item is not updated for a longer time even if the value is below 4.
Let’s assume the value remains at 3.5 for 1 hour, the rule is not triggered. On the other hand it can happen that it is constantly triggered since the item value is below 4 but varies…
Just to explain what I want to do:
I put a plug with energy measurement at my washing mashine. I want to get notified if the washing program is finished. I figured out that if the energy consumption is 4 Watts or lower it’s finished.
In OH 2 I had a “text based” rule:
rule "React on Leistung (Waschen_Power) change/update"
when
Item Waschen_Power changed
then
if (Waschen_Timer.state == OFF) {
val wpwr = Waschen_Power.state as Number
val pwrthreshold = 4
if (wpwr <= pwrthreshold){
sendTelegram("cmhomebot","OpenHAB Info - Wäsche ist fertig")
sendCommand(Waschen_Switch, OFF)
sendTelegram("cmhomebot","OpenHAB Info - Stromzufuhr für Wäsche abgeschaltet ")
}
}
end
which worked perfectly. I now try to achieve the same with the UI based config of OH3.