[SOLVED] Time of Day rule not working

Dear Community!

I have some problems with this approach. I got several error, however I found some of them, but now I’m stuck.

I get always this error:

2018-07-17 18:59:01.330 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'Calculate time of day state': Could not cast NULL to org.eclipse.smarthome.core.library.types.DateTimeType; line 31, column 39, length 35

Which is where it converts the Evening Time to Joda DateTime.

ateTime vEvening_Time "Afternoon [ %1$tH:%1$tM]" <sunset> { channel="astro:sun:minus90:set#start" }

What is wrong with this? The other items has a ‘local’ prefix (the name of the Sun Thing) like this:

DateTime vSunrise_Time "Day [%1$tH:%1$tM]" <sun> { channel="astro:sun:local:rise#start" }

If I view this items on a sitemap, all works, and shows the correct times, except the Evening Time. What’s wrong with this? Something changed in 2.3.0?

Thanks for help!

Please post the line 31 of the .rules file this Rule resides in. Just to double check.

But I can probably tell you the cause of the error.

NULL is the state that Items possess when they have not yet received a value from the binding. Whenever you restart OH or change a .items file all those files will be reloaded and their state will be set to NULL.

So in this case your Item vEvening_Time is not getting a value from the Astro binding before the Time of Day Rule runs.

So the first thing to ask, do you have an astro:sun:minus90 Thing defined?

Line 31:

  val afternoon_start = new DateTime((vEvening_Time.state as DateTimeType).getZonedDateTime.toInstant.toEpochMilli)

I don’t have a seperate Thing for that, I thought that because vEvening_Time channel is set to minus90, it will return the correct time in that item. How should I define a Thing for this?

There are also two ways to define an offset for the Astro binding. You can define the offset on the Thing or you can add 15 degrees to the latitude to add 60 minutes.

So create a new Thing called astro:sun:minus90 and configure it with a -90 minute offset in PaperUI or subtract 22.5 to the latitude to offset all the events for that Thing by -90 minutes.

So I should have two Sun Thing yes? And I will use this second Thing to these items which needs offset, right?


1 Like

Thanks for your help!