Time not correct in OH3 and eventlog

Hi,

I’m Runnng OH 3.0.0 M2 on a Ubuntu server. The time on the Ubuntu server shows the correct time…
Installed the NTP binding which is ONLINE and defined a Item “Date” in the items file.
If you see in the event.log the timestamp runs 1 hour behind the ntp time which is the correct time.
Also if i show this date in the MainUI the time runs 1 hour behind?

Where end how can i correct this?

What time zone did you configure in OH itself?

You can check this in PAPER UI

Configured Time Zone in MainUI

Not in OH3. :wink:

In OH2 it is possible to check the timezone in the karaf console with

env | grep timezone

does this show the same timezone in your case ?

Hi Wolfgang,

Just checked that in Karaf. It shows UTC timezone where i need CET.

image

How to change this?

Found the Solution: In the folder /etc/default change the parameter EXTRA_JAVA_OPTS in the file with the command “vim openhab” to

EXTRA_JAVA_OPTS="-Duser.timezone=Europe/Brussels"

Save and rebooted the system.
The timestamps in the logfiles and time in the ManUI are correct!

Thanks a lot for your help!

2 Likes

Thanks for this. I just installed OH3 and had the same issue. In openhabian you can change the time zone in the openhabian-config settings, but I would have expected it to pick the time zone up when you set it in the MainUI setup wizard.

I wonder if this should be reported as a bug?

I know when using docker it needs to be passed in EXTRA_JAVA_OPTS.

So I have the same issue with my new Openhab3 install on debian. The system all looks correct:

admin@openhab3:/$ timedatectl
Local time: Wed 2021-01-06 19:12:18 AEDT
Universal time: Wed 2021-01-06 08:12:18 UTC
RTC time: n/a
Time zone: Australia/Sydney (AEDT, +1100)
System clock synchronized: yes
NTP service: inactive
RTC in local TZ: no

but my openhab logs and rules are an hour behind. When I check the karaf console I see it’s behind there and it looks to be due to:

String user.timezone GMT+10:00

Sydney is currently on daylight savings so it’s GMT+11. I think it got this value from the Regional -> Time Zone setting in the GUI and I would say the bug is that is should not be setting GMT+10 but Australia/Sydney so it will change with DST, but now I tried to set the Time Zone to nothing (gui says it will use underlying machine timezone) and even to another zone (that is GMT+11 so at least my stuff will be on time for now) but even with a bounce and a cleared cache I cannot change this value or see where it is set in the configs.

I know I can implement the EXTRA_JAVA_OPTS but that surely can’t be the answer here as it potentially means getting users to dick around on the backend. Is this affecting others? (possibly only those in the Southern hemisphere??)

I’m in Canada, so no. :wink:

My system time was set to +0100, same as @BartVdP, even though I specified America/Vancouver in the setup wizard.

So should I log 2 bugs?

  1. Numbers instead of place being used in timezone via GUI (which I assume sets karaf)
  2. Unable to make changes via GUI after initial install.

I’d like some more confirmation it’s affecting other users (possibly on the lastest snapshot) before I put this together.

I’m not a developer, but from a user perspective I think this amounts to, “setting the time zone in Main UI (either by setup wizard or in Region Settings) does not change system time.”

For clarity, I did a fresh openHABian install and specified my time zone in the setup wizard. That was properly reflected in the Region Settings, but my system time didn’t change until I used openhabian-config.

As you say, though, I wonder why others haven’t come across this issue, unless it’s specific to the current stable release.

I think it’s cause the Americas and Europe are not in daylight saving yet…

Not for me. Pacific Time is +8, and my system was +1. So it could be a different issue.

Strangely after bouncing openhab to fix another issue, I see that even with my GUI setting reflected in the log

2021-01-08 16:14:10.472 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to ‘Asia/Magadan’.

which I did to hack my time to UTC+11, when checking the karaf console, I see

String user.timezone Australia/Sydney

and now my openhab logs are the correct time. Not sure how this has happened…

Strange behaviour…
I’m sure that when i set the timezone in the OH setup wizard and restarted the application the time was not corrected. Only after setting the EXTRA_JAVA_OPTS the time was corrected!
Indeed this is not the correct way to do this! It should work via the OH setup…
Don’t know how to report this as a bug but feel free to do so!

I think it’s via github, I’ll have a look

Just an update, I discovered that when /etc/timezone is a flat file with Australia/Sydney in it, Karaf reads it fine, but when it is a softlink to /usr/share/zoneinfo/Australia/Sydney, Karaf shows UTC+10.

During my troubleshooting I think I used timedatectl to set my timezone to the same zone it already was (Australia/Sydney) and that set the flat file which is why it suddenly started working.

This is probably a bug in apache karaf not openhab, although the question still remains why the value set in Openhab Gui (currently Asia/Magadan) does not get picked up by karaf.

I fixed the issue on my system (openhabian-pi-raspios32-v1.6.3.img)

  • use SSH or Putty to connect to the rpi
  • Edit the /etc/timezone file. You will need to use ‘sudo’ to edit system files. In my case it was “US/Central”
  • use “sudo sync” to flush all changes to disk
  • use “sudo reboot” to restart your system