Wrong time in openHAB Docker Container on Synology
January 5, 2020I recently moved my openHAB installation from a Raspberry Pi to a Docker installation running on my new Synology Diskstation. The whole process worked basically flawless until I noticed that some (time-dependent!) rules would not fire. Or rather - fire an hour late.
The Problem
Looking in the the log files I realized that the timestamps in there were off by an hour.
...
2020-01-05 19:12:19.439 [INFO ] [pse.smarthome.model.script.pir.rules] - ...
2020-01-05 19:12:29.683 [INFO ] [pse.smarthome.model.script.pir.rules] - ...
2020-01-05 19:16:02.959 [INFO ] [pse.smarthome.model.script.pir.rules] - ...
...
However, the system time on the Synology Diskstation was correct, so this was obviously an issue with the openHAB Docker container.
The Solution
The solution I came up with wa setting the timezone using the EXTRA_JAVA_OPTS
environment variable like this:
Stop the container
Edit
the container, find theEnvironment
tab inAdvanced Settings
and add this entry.
EXTRA_JAVA_OPTS=-Duser.timezone=America/New_York
Valid settings for the timezone value can be found here.
Start the container again.
Done, time is correct now.