var Number last_count = 0.00 var Number diff = 0.00 rule "Convert Wmin to KWh" when Item Shelly1_2_PM_Energie received update then // Initialer Start - die drei folgenden Zeilen auskommentieren und anschließend einen Zählimpuls auslösen damit das Regelwerk einmal durchlaufen wird! // postUpdate(Shelly1_2_PM_Gesamtverbrauch, 0.0) // postUpdate(Shelly1_2_PM_Tagesverbrauch, 0.0) // postUpdate(Shelly1_2_PM_Intervallverbrauch, 0.0) // if ( Shelly1_2_PM_Energie.state == 0.00000000 ) { diff = 0.00 last_count = 0.00 } diff = ((Shelly1_2_PM_Energie.state as DecimalType / (1000*60)) - last_count ) postUpdate(Shelly1_2_PM_Intervallverbrauch, (Shelly1_2_PM_Energie.state as DecimalType / (1000*60))) logInfo("shelly1_2_pm.rules", "Strom Intervallverbrauch kWh: " + Shelly1_2_PM_Intervallverbrauch.state) last_count = Shelly1_2_PM_Intervallverbrauch.state postUpdate(Shelly1_2_PM_Tagesverbrauch, (Shelly1_2_PM_Tagesverbrauch.state as DecimalType + diff )) logInfo("shelly1_2_pm.rules", "Strom Tagesverbrauch kWh: " + Shelly1_2_PM_Tagesverbrauch.state) postUpdate(Shelly1_2_PM_Gesamtverbrauch, (Shelly1_2_PM_Gesamtverbrauch.state as DecimalType + diff )) logInfo("shelly1_2_pm.rules", "Strom Gesamtverbrauch kWh: " + Shelly1_2_PM_Gesamtverbrauch.state) end rule "Reset Strom Tagesverbrauch" when Time is midnight then // executeCommandLine("/etc/openhab2/scripts/log_gas_tagesverbrauch.sh"+"@@"+Gas_Tagesverbrauch.state+"@@"+Gas_Gesamtverbrauch.state ) postUpdate(Shelly1_2_PM_Tagesverbrauch, 0.0) end