I’m trying to create a rule that triggers when my Popp zwave switch/power meter is turned on, but registering less than 3 watts of power (i.e. because the device plugged in has turned off).
The device itself works fine, with the following items file:
Switch FooSwitch "Foo state" {zwave="3:command=switch_binary,refresh_interval=10"} Number FooPower "Foo Power [%.1f W]" <energy> (Metering) { zwave="3:command=METER,meter_scale=E_W" }
I can turn it on/off and see the power usage. But I can’t work out how to make a rule that’s triggered if the device is on AND the power is less than 3 watts. I think I can create a variable holding the power with
var double t = new Double(CoffeePower.state.toString())
but I can’t do that outside the rule, and I can hardly have the rule triggered by a variable defined in the rule itself.
Maybe trigger on the change in FooPower, but then in the body of the rule, further check the other conditions?
import org.openhab.core.library.types.*
rule Foo
when
Item FooPower changed
then
if ((FooPower.state as DecimalType) < 3 && FooSwitch.state == ON) {
// do stuff
}
end
Doesn’t the Popp support associations? If so, you shouldn’t use refresh_interval - you should set the association… Associations will automatically report changes without the need for additional traffic of polling…