Not sure whether this applies here too, but from Design Patterns Time of Day (Design Pattern: Time Of Day), I took:
val long sunrise = new DateTime((Sunrise_Time.state as DateTimeType).calendar.timeInMillis).millis
which works with
now.isAfter(sunrise)
(Sunrise_Time it self is an item that is linked to the astro binding)
date conversion confuse me easily but I believe you need to import import java.util.Date
You may want to read through the whole post
Edit: this rather old post clarified a few things, at least for me
For both X and Y can be either variables if you want to control it that way or just numbers. Then you can use the now.isAfter(Opening) for a true/false check.
I tried it the way it was posteed in the “old” thread (including the imports):
val DateTime CheckTimeStart = new DateTime((Opening.state as DateTimeType).calendar.currentTimeMills)
if (now.isAfter(CheckTimeStart)&& now.isBefore(CheckTimeEnd) {
and I get:
22:37:57.903 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule Benzinpreise: An error occured during the script execution: The name ‘.currentTimeMills’ cannot be resolved to an item or type.
Not sure what you want to accomplish, but if you want the read the current time and compare it to a setpoint or similar, you may want to look this excellent post: Time of Day Events
the first term give you the time rounded to full minutes and compares it to another time also rounded to full minutes.
Works like a charm for me.
Thanks for the second help in here. My failure was to copy from the “rather old” thread instead of directly from your post.
So I used: “calendar.currentTimeMills” instead of "calendar.timeInMillis"
Works like a charm now.