Hi all,
I would like to calculate an end time from a start time and a duration in a rule.
start time and end time are DateTime items.
duration is a Number item.
I have read all the DateTime explanations and tutorials, but somehow still fail.
Here is my code:
.items:
DateTime IrrigationStarted "Bewässerung letzter Start [%1$td.%1$tm.%1$tY %1$tH:%1$tM]" <time> // virtual item, rule setting, mapdb persistence
DateTime IrrigationEndTime "Bewässerung Ende [%1$td.%1$tm.%1$tY %1$tH:%1$tM]" <time> // virtual item, rule setting, mapdb persistence
Group:Number:SUM gIrrigation_Times "Total Irrigation Time is [%d mins]"
.rules
// does not work: Could not invoke method: org.joda.time.DateTime.plusMinutes(int) on instance: 2019-06-27T21:40:16.535+02:00
IrrigationEndTime.postUpdate(now.plusMinutes(gIrrigation_Times.state as Number) as DateTimeType)
IrrigationEndTime.postUpdate(new DateTimeType(now.plusMinutes(gIrrigation_Times.state as Number)))
IrrigationEndTime.postUpdate(now.plusMinutes(gIrrigation_Times.state as Number).intValue)
// Does not work: Cannot cast from DateTime to DateTimeType
IrrigationEndTime.postUpdate(now.plusMinutes(gIrrigation_Times.intValue) as DateTimeType)
Maybe I cannot use .plusMinutes here and have to convert the DateTime item to .toEpochMilli, do the sum and convert back?
Any help is appreciated.