I struggle using DateTime and Persistence in a rule.
I want to calculate the energy consumption for an hour, today and the last week.
I am using the Libraries from Helmut Lehmeyer.
Does anyone have an example how to use historicState or deltaSince for the PersistenceExtension.js?
I am able to get a DateTime with the actual time
var test = new DateTime(now().toString());
Using this with historicState yields an Error …
todayEnergyConsumption = historicState(totalEnergyConsumption.name, test );
Using a DateTimeType as
var test = new DateTimeType(now().toString());
yields a ClassCastException …
Cannot cast org.eclipse.smarthome.core.library.types.DateTimeType to org.joda.time.base.AbstractInstant
I appreciate any examples, hints, documents etc.
THANKS in advance