// Oven State Machine
rule "Oven Consumption State Machine"
when
Item Qubino_Oven_MeteredWallPlug_SensorPower changed
then
if ((Qubino_Oven_MeteredWallPlug_SensorPower.averageSince(now.minusMinutes(5)) as Number) == 0.0) Oven_OpState.postUpdate("offline")
else if (Qubino_Oven_MeteredWallPlug_SensorPower.state < 0.5) Oven_OpState.postUpdate("standby")
else if (Qubino_Oven_MeteredWallPlug_SensorPower.state > 1) Oven_OpState.postUpdate("running")
end
the error is this:
[ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Oven Consumption State Machine': Division undefined
rule "Oven Consumption State Machine"
when
Item Qubino_Oven_MeteredWallPlug_SensorPower changed
then
if ((Qubino_Oven_MeteredWallPlug_SensorPower.averageSince(now.minusMinutes(5)) as Number) == 0.0){
Oven_OpState.postUpdate("offline")
}
else if (Qubino_Oven_MeteredWallPlug_SensorPower.state < 0.5){
Oven_OpState.postUpdate("standby")
}
else if (Qubino_Oven_MeteredWallPlug_SensorPower.state > 1){
Oven_OpState.postUpdate("running")
}
end
Maybe a far fetched idea, but averageSince works only if you (a) have persistence and (b) persist your items with everyMinute strategy. Maybe check your persistence strategy for this.
Number Qubino_Oven_MeteredWallPlug_SensorPower "Power in real-time [%.2f W]" (gFF_Kitchen, gPowerMeters, gIPowerRealTime, gChart, gHistory)
gChart is rrd4j persistence strategy (everyMinute)
gHistory is influxdb persistence strategy (everyHour)
I have also mapdb persistence for default persistence strategy (restoreOnStartup)
the Qubino wall plug is reporting 0.00 and 0.10/0.20 when the device is in standby (was not expecting 0.00). So calculating the average in the last 5 minutes (expecting different from 0), I’m trying to differentiate “offline” from “standby”.
Still going on a hunch…unless rrd4j is your default service, you may pull the wrong database (mapdb persists only always one value, and everyHour would not give you the data you need for your calculation)
So maybe this is not the right tool for reach the goal … actually I don’t know how to say “use the rrd4j strategy for that computation” instead of mapdb or influxdb
// Oven State Machine
rule "Oven Consumption State Machine"
when
Item Qubino_Oven_MeteredWallPlug_SensorPower changed
then
if ((Qubino_Oven_MeteredWallPlug_SensorPower.averageSince(now.minusMinutes(5), "rrd4j") as Number) == 0.0) {
Oven_OpState.postUpdate("offline")
}
else if (Qubino_Oven_MeteredWallPlug_SensorPower.state < 0.5) {
Oven_OpState.postUpdate("standby")
}
else if (Qubino_Oven_MeteredWallPlug_SensorPower.state > 1) {
Oven_OpState.postUpdate("running")
}
end
Any suggestion how my rule should work better?
I mean, how to solve the issue above (I see “offline” sometimes, even if the device is ON and in standby)?