Ok, first things first,
Please use the code fences when publishing code:
So your ule is:
import org.openhab.model.script.actions.*
rule “Pool_ Filter”
when
Item pool_filter_preasure changed
then
habpcmd.sendCommand(“SCREEN_ON”)
Thread::sleep(29000)
if (pump.state == ON && pool_filter_pressure.state > 270) {
pushNotification(“Information”, “Filter Preasure High!”)
pump.sendCommand(OFF)
}
else if (pump.state == ON && pool_filter_preasure.state < 170) {
pushNotification(“Information”, “Filter Preasure Low!”)
pump.sendCommand(OFF)
}
end
Remove the import, you don’t need it
Use indents
Thread:sleep has it’s uses but a long one is a very bad idea:
So use a timer:
rule “Pool_ Filter”
when
Item pool_filter_preasure changed
then
habpcmd.sendCommand(“SCREEN_ON”)
createTimer(now.plusSeconds(29), [ |
if (pump.state == ON && pool_filter_preasure.state > 270) {
pushNotification(“Information”, “Filter Preasure High!”)
pump.sendCommand(OFF)
}
else if (pump.state == ON && pool_filter_preasure.state < 170) {
pushNotification(“Information”, “Filter Preasure Low!”)
pump.sendCommand(OFF)
}
])
end
That’s the first rule