"now" to Item(DateTime)

In Blockly I save “now” to a DateTime-Item. In first view it work’s fine. But then I realized that there is a gap of “one hour” to real time. I checked time in openhab 4.2 and linux time. Everything is fine.

Only if I save “now” to Item(DateTime) I get a difference of one hour. What can I do? Any ideas?

show us your code so we can try to reproduce it

show us your code so we can try to reproduce it

This is from Blockly generated Code.

if (items.getItem(‘motionFloor1_EG_Stairs’).state == ‘ON’) {
items.getItem(‘motionLastFloor1_EG_Stairs’).sendCommand((time.ZonedDateTime.now()));
items.getItem(‘motionLastFloor_Stairs’).sendCommand((time.ZonedDateTime.now()));
items.getItem(‘motionLastBuilding’).sendCommand((time.ZonedDateTime.now()));
}

I can’t reproduce this:

image

console.info((time.ZonedDateTime.now()));

2024-08-25 15:54:32.489 [INFO ] [myrule] - 2024-08-25T15:54:32.485+02:00[SYSTEM]

(log time entry is identical to logged time of now)

At console “openhab-cli showlogs” it’s fine.

2024-08-25 23:41:00.557 [INFO ] [nhab.automation.script.ui.lastMotion] -
2024-08-25T23:41:00.556+01:00[SYSTEM]

But in GUI / Item(DateTime) I have a difference of one hour.

So, first of all, it is not related to Blockly then (and therefore I would recommend to change the title of the post to attract other people).

I would bet you see 15:54:32 in the UI instead of 17:54:32.485, correct? Hence, in the UI you miss the timezone-shift of 2 hrs. Can you confirm?

Click on State Description and make sure it is NOT set!

What does it show here?

  • When you say in the UI it is different: where exactly and what do you show it with?

Yes, I would say that I miss timezone-shift of 1 hrs. In Screenshot is this gap of 1 hrs too. Real time is 12:48:25 and NOT 11:48:25 like in screenshot.

My item definition (item created in OpenHab 4.2.0):

Yes, State Description is NOT set. But in your screenshot “Metadata > State Description” look’s different to my screenshot, or? This remembers me to this.

I am running out of ideas. Let me ask our beloved @rlkoshak if he has an idea…

If the Item’s state is correct but it is showing an hour off in the UI, the problem is the timezone setting on the machine running the browser or the timezone setting of the browser itself. The UIs will convert all DateTimes to the timezone reported by the browser.

I checked in Google Chrome and Microsoft Edge. I can’t find timezone settings. The running machine is fine. Correct time and timezone. But it was a hopeful idea.

Your JVM timezone may also be checked.

JVM timezone? That`s new for me. How can I check it?

The Raspberry (server) and client computer has correct time.
Openhab has correct timezone settings.

JVM timezone can be set with EXTRA_JAVA_OPTS:

EXTRA_JAVA_OPTS="-Duser.timezone=Europe/Oslo"
1 Like

That was it!! Thanks a lot… I’m not sure if it was necessary, but I stopped and restarted openhab.

Now I’ve only a gap of 30 seconds between now() and “Digital Clock Card”(Page-building) :smiley: