Hello again,
I have the following Problem with a rule. If These rules is executed, I get the following error:
Rule ‘Stromzähler Verbrauch aktuell’: An error occurred during the script execution: index=1, size=1
The rule:
rule "Stromzähler Verbrauch aktuell"
when
Item test_switch changed
//Time is midnight
then
var int weekday = now.getDayOfWeek //Montag = 1 ... Sonntag = 7
//Verbrauch Tag aktuell
postUpdate(Stromzaehler_Verbrauch_1T_aktuell, (Stromzaehler_Stand.deltaSince(now.withTimeAtStartOfDay(),"influxdb") as DecimalType))
//Verbrauch Woche aktuell
if (now.getDayOfWeek.intValue == 1) {
postUpdate(Stromzaehler_Verbrauch_7T_aktuell, (Stromzaehler_Stand.deltaSince(now.withTimeAtStartOfDay(),"influxdb") as DecimalType))
var Number temp4 = Stromzaehler_Verbrauch_7T_aktuell.state
logInfo("rule", "Der Stromverbauch der aktuellen Woche wurde berechnet und beträgt: " +String.format("%.2f",(temp4).floatValue())+ " kWh")
}
else {
logInfo("rule", "Test")
var int calc1 = weekday-1
var Number calc11 = calc1 as Number
logInfo("rule", "Test2")
var Number calc2 = Stromzaehler_Stand.deltaSince(deltaSince(now.minusDays(calc11)),"influxdb")
var Number calc3 = Stromzaehler_Stand.deltaSince(now.withTimeAtStartOfDay(),"influxdb")
var Number calc4 = calc2 + calc3
postUpdate(Stromzaehler_Verbrauch_7T_aktuell, calc4)
logInfo("rule", "Der Stromverbauch der aktuellen Woche wurde berechnet und beträgt: " +String.format("%.2f",(calc4).floatValue())+ " kWh")
}
logInfo("rule", "Stromverbraeuche wurden berechnet")
end```
I think there is an error with the variable but I don't know what to do.
Any ideas?
Thanks for your help guys!