Set future time for DateTime item with rule (text or blockly)

Hi all

I’m in the need for setting a time in the future, I would like an item that allways holds tomorrows date and time 06:00.

So a basic idea of what I want to achive is as below, but I doesn’t work. When I build wit blockly it cannot parse date

DateTime EvCarReady “När ska bilen vara laddad”

rule "EV ready"
Time cron "0 0 6 ? * * *"

Error code from blockly rule execution

06:45:12.529 [WARN ] [ernal.defaultscope.ScriptBusEventImpl] - State ‘2022-09-03T06:45:12.516582+02:00[Europe/Stockholm]’ cannot be parsed for item ‘EvCarReady’.

I hope anyone could give me a clue

Hi again I found out that this could work, but how do I do if I want to set nextdatee as tomorrow at 06:00 when a rule fires at for instance 14:00, in joda there was a function startoftoday or similar. But is there an equalent method for zonedatetime?

rule "EV ready"
Time cron "0 0 6 ? * * *"
EvCarReady.postUpdate (new DateTimeType(now.plusDays(1)))

Sure. now.with(LocalTime.MIDNIGHT).plusHours(30)

Worked as a charm, I would never figured that one out myself, I will use that one but triggerd by another event now when I can have it set to 06:00 whenever the rule fires… I beleive that time is really difficult to handle. I have another project where I try to use a DateTime item in a ECMA 11 script but get stuck on errors. But this piece is one piece in the puzzle.

Unfortunately that will break on DST changeovers and tomorrow the time will be one hour off.


should handle that transition better.

Note, look up the method names on ZonedDateTime, I’m going from memory here and it might be slightly different (e.g. withMinuteOfHour, withMinute, etc).

See Working with Date Times in JS Scripting (ECMAScript 11).

1 Like

I did find some text about it but it’s a little like a needle in a haystack, it seems like I foud the correct syntax for this, but that somethoings is missing when trying to update DateTime item. I thought .toString would have worked out.

command in .rules file



Cannot convert '2022-09-07T06:00+02:00[Europe/Stockholm]' to a state type which item 'EvCarReady' accepts: [DateTimeType, UnDefType].

The Item would like you to send it an ISO string

The easiest way to post a ZonedDateTime to a DateTime Item right now is to convert it to a LocalDateTime first which will strip off the troublesome time zone.


Thanks alot for the moment that made my script work. Thanks alot.