Error during the execution of rule: org.eclipse.smarthome.core.library.types.DateTimeType

Hi folks

I get the following error during the execution of my rule, See both below:


2017-12-20 08:29:01.112 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule XYZ: org.eclipse.smarthome.core.library.types.DateTimeType

Rule extract:

import org.joda.time.*

var Timer tRandomLights = null
var randomStarter = null

rule "XYZ"
Time cron "0 */10 7-23 * * ?"
if (now.isBefore((Sunrise_Time.state as DateTimeType).calendar.timeInMillis) || now.isAfter((Sunset_Time.state as DateTimeType).calendar.timeInMillis)) {


I have installed the astro binding and created the items Sunrise_Time and Sunset_Time. The rule should be invoked every 10 minutes and work after sunset and before sunrise. But there seems to be an issue with the IF statement


first: On which build of OH are you?
if on OH2,you won’t Need to import joda.time.

second: I guess, you’re referring to:

can you post your items file declaring Sunrise_Time and Sunset_Time?


I am on openHAB 2.1.0-1.

I deleted the joda.time import but this doesn’t solve the problem.

The items are declared as follows:
DateTime Sunrise_Time “Sunrise [%1$tH:%1$tM]” {astro=“planet=sun, type=rise, property=end”}
DateTime Sunset_Time “Sunset [%1$tH:%1$tM]” {astro=“planet=sun, type=set, property=start”}


At first, please use hypens (``` for your Code, makes it better to read or use some of those neat Icons on the right side for code fences).

Then to your code. I think, you’re using the actual “Astro”-binding for openHAB2, which means, there’s Things and Channels. Therefore, the code you’re using is for Astro1-binding, which was developed for openHAB1.x

Please check Astro Binding for reference and try this:

DateTime Sunrise_Time       "Sunrise [%1$tH:%1$tM]"  { channel="astro:sun:home:rise#end" }
DateTime Sunset_Time        "Sunset [%1$tH:%1$tM]"   { channel="astro:sun:home:set#start" }

but be sure to use a thing-Definition first (change your geo-location):

astro:sun:home  [ geolocation="52.5200066,13.4049540,100", interval=60 ]

Hi Thomas

Thanks a lot. The item definition was the problem. I fixed it with the suggested definition and the rule now works without any error!