- Platform information:
- Hardware: Raspberry Pi 3 Model B Rev 1.2_
- System: Host: rpi3ohv2 Kernel: 5.4.51-v7+ armv7l bits: 32 Console: tty 2
- Distro: Raspbian GNU/Linux 10 (buster)
- OpenJDK Runtime Environment (Zulu 8.31.1.122-linux_aarch32hf) (build 1.8.0_181-b122)
- Version: 2.5.10 (Build) (apt-get), text-based config
- binding = astro,exec,logreader,network,ntp,systeminfo,fritzboxtr0641,expire1,mqtt1,weather1
- ui = paper,basic,classic,restdocs
- persistence = rrd4j,mapdb
- action = mail,mqtt
- transformation = map,javascript,xslt,scale,jsonpath
I am trying to evaluate a time calculation w/o success. The rule
rule "Sonoff: Shed_NLO_PIR timer"
when
Item Shed_NLO_PIR received update ON
then
val Integer remainingTimeThreshold = 60 * 1000
if (now.millis - Shed_NLO_PIR_LUP.lastUpdate.millis < remainingTimeThreshold)
{
logInfo("Sonoff.2.05", "Shed_NLO_PIR_LUP now - LUP....: {} sec", now.millis - now.millis - Shed_NLO_PIR_LUP.lastUpdate.millis)
}
… it produces an error:
2020-11-08 15:12:06.369 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Sonoff: Shed_NLO_PIR timer': cannot invoke method public abstract long org.joda.time.ReadableInstant.getMillis() on null
The more I think about this DateTime not being DateTimeType and all, I’d like to ideally convert all to millis() and work with that…0.
The calendar method is deprecated:
val DateTime lup = new DateTime ((Shed_NLO_PIR_LUP.state as DateTimeType).calendar.currentTimeMillis)
According to the docs, this shoudd work:
val Number lup = (Shed_NLO_PIR_LUP.state as DateTimeType).zonedDateTime.timeInMillis
…, but it doesn’t!
It errors with:
2020-11-08 15:36:08.152 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Sonoff: Shed_NLO_PIR timer': 'timeInMillis' is not a member of 'java.time.ZonedDateTime'; line 50, column 26, length 67
Any hints appreciated.