I want to monitor my wasching machine using a fritz!dect 200 power plug. Basically it’s working, But as the power is not just going to zero, when the machine finished, I’ve got some trouble with too many notifications.
The following is my rules files (sorry for the ugly coding;-):
var boolean vvWaschmaschineAn = false
rule "Waschmachinenerkennung"
when
Item Waschmaschine_Verbrauch changed // Sobald der Verbrauch sich ändert
then
logInfo("RULE", "--> Rule: Waschmaschinenerkennung hat gegriffen")
var double wv=(Waschmaschine_Verbrauch.state as DecimalType).doubleValue
// logInfo("WV:", wv.toString())
if(wv > 5){
if (vvWaschmaschineAn == false){
logInfo("RULE", "AN: 1 x warten")
Thread::sleep(60000) // 60000 Warte eine Minute
if(wv >5){
logInfo("RULE", "AN: 2 x warten")
Thread::sleep(6000) // 60000 Warte eine Minute
if(wv >5){
logInfo("RULE", "AN: 3 x warten")
Thread::sleep(60000) // 60000 Warte eine Minute
if(wv >5){
vvWaschmaschineAn = true
postUpdate(vWaschmaschineAn, ON)
logInfo("RULE", "--> Waschmachine an ON")
setMasterVolume(new PercentType(50))
// say("Hallo. Die Waschmaschine läuft")
}
}
}
}
}
if(wv < 5){
//if(wv < 1 && vWaschmaschineAn == ON){
if (vvWaschmaschineAn == true){
logInfo("RULE", "AUS: 1 x warten")
Thread::sleep(60000) // 60000 Warte eine Minute
if(wv < 5){
logInfo("RULE", "AUS: 1 x warten")
Thread::sleep(60000) // 60000 Warte eine Minute
if(wv < 5){
logInfo("RULE", "AUS: 2 x warten")
Thread::sleep(60000) // 60000 Warte eine Minute
if(wv < 5){
vvWaschmaschineAn = false
postUpdate(vWaschmaschineAn, OFF)
logInfo("RULE", "--> Waschmachine an OFF")
setMasterVolume(new PercentType(50))
// say("Hallo. Die Wäsche ist fertisch.")
}
}
}
}
}
end
have you finish your code?
I also have the Frits Dect 200 and would like to monitor my washing machine.
Maybe you could publish your final code as a tutorial.
no, I din’t finish that one, finally I gave up. It was not difficult to monitor the washing machines energy consumption. But the trigger points, that I identified when my washing maschine = ON/OFF, were not really reliable. I think this really depends on your individual washing maschine and the different programs, it can run.
here is my complete setup - requirements: avmfritz binding, map transformation, rrd4j persistence. It’s based on the tutorial above and as @Matt_Hias already mentioned the challenge is to find the right values for your washing machine. I removed the calculation of the costs and the CO2 emissions in the report. Ping me if you are interested.
fritz.items
Number fritzWashingMachineDECT200Power "Aktuelle Leistung [%.2f W]" <energy> { channel="avmfritz:FRITZ_DECT_200:192_168_XXX_XXX:AAAAAAAAAA:power" }
Number fritzWashingMachineDECT200Energy "Gesamtverbrauch [%.3f kWh]" <energy> { channel="avmfritz:FRITZ_DECT_200:192_168_XXX_XXX:AAAAAAAAAA:energy" }
household.items
Number householdWashingMachineState "Aktueller Status [MAP(household-de.map):%s]" <washingmachine_2>
DateTime householdWashingMachineLastChange "Letzte Änderung [%1$tA, %1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS Uhr]" <time>
household.rules
val STATE_OFF = 0
val STATE_STANDBY = 3
val STATE_ACTIVE = 2
val STATE_FINISHED = 1
rule "FRITZ!Box - fritzWashingMachineDECT200Power changed"
when
Item fritzWashingMachineDECT200Power changed
then
// Washing Machine State Machine
if( fritzWashingMachineDECT200Power.state < 0.2 ) householdWashingMachineState.sendCommand(STATE_OFF)
else if( fritzWashingMachineDECT200Power.state > 11.0 ) householdWashingMachineState.sendCommand(STATE_ACTIVE)
else if( fritzWashingMachineDECT200Power.averageSince(now.minusMinutes(2), "rrd4j") > 5.0 ) {
if( householdWashingMachineState.state == STATE_OFF ) householdWashingMachineState.sendCommand(STATE_STANDBY)
} else {
if( householdWashingMachineState.state == STATE_ACTIVE ) householdWashingMachineState.sendCommand(STATE_FINISHED)
}
end
rule "Household - householdWashingMachineState changed"
when
Item householdWashingMachineState changed
then
val thisChange = new DateTimeType()
// create report if washing machine is finished
if( householdWashingMachineState.state == STATE_FINISHED ) {
// get last change
val lastChange = householdWashingMachineLastChange.state
val startTime = new DateTime(lastChange.toString)
val endTime = new DateTime(thisChange.toString)
// calculate running time
val seconds = (endTime.millis - startTime.millis) / 1000
val totalMinutes = seconds / 60
val remainderSeconds = seconds % 60
val totalHours = totalMinutes / 60
val remainderMinutes = totalMinutes % 60
// get energy consumption
var Number diffEnergy = fritzWashingMachineDECT200Energy.deltaSince(startTime, "rrd4j")
// deltaSince returns null value if some data is missing in persistence
if( diffEnergy === NULL ) {
val avgPower = fritzWashingMachineDECT200Energy.averageSince(startTime, "rrd4j")
diffEnergy = avgPower * 0.024// 24 / 1000 = 0.024
}
val message = "Waschmaschine ist fertig.\n\n" +
"Aktueller Status: " + householdWashingMachineState.state.toString + " (" + transform("MAP", "household-de.map", householdWashingMachineState.state.toString) + ")\n" +
"Start: " + lastChange.format("%1$tA, %1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS Uhr") + "\n" +
"Ende: " + thisChange.format("%1$tA, %1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS Uhr") + "\n" +
"Laufzeit: " + String::format("%02d", totalHours) + "h " + String::format("%02d", remainderMinutes) + "m " + String::format("%02d", remainderSeconds) + "s\n" +
"Verbrauch: " + String::format("%.3f", diffEnergy.floatValue) + " kWh\n"
// send notification message
// TODO
}
// remember this change
householdWashingMachineLastChange.postUpdate(thisChange)
end