Wrong time zone! NTP bindings

Greetings to all!!!
I’m sorry, I do not know much English, I communicate through a translator.

I have a problem with time zone.
In item:
DateTime MyDate "Date [%1$td %1$tb %1$tY %1$tT]" <calendar> { ntp="Europe/Moscow:ru_RU" }

And now show timе in OpenHAB:
11:45

But, now the correct Moscow time:
10:45 (+3)

If I use a time zone other city, it is synchronized with a PC, for example, the chart shows the value of one hour later.

How do I fix this?

Thanks. Kirill

openHAB uses the timezone settings of the computer it is running on. Check what your computer’s timezone is (on Linux use the command cat /etc/timezone) and see if it is correct. If not, there is often a command called tzselect which will help you set the timezone.

1 Like

Hi, Rich Koshak, Thanks for answering.

root@raspberrypi: ~# cat /etc/timezone
Europe/Moscow

In system time now: 9:20. This is correct Moscow time. Automatic synchronization.

In item:
DateTime MyDate "Date [%1$td %1$tb %1$tY %1$tT]" <calendar> { ntp="Europe/Moscow:ru_RU" }

Show timе in OpenHAB: 10:20

I’m using NTP.binding

What else can you do?

I’m at a loss. Not sure what to do as OH gets the timezone from the system and doesn’t manage it on its own.

Why do you say that OH gets time zone from the system?
Why, when I turn off connect to the global Internet, item it does not show anything.
Show is:
- - - -
I thought that OH gets time from the ntp servers, because it is binding.ntp.
Is not it?

That indicates that the Item is Undefined. For some reason the NTP binding is not working or it hasn’t pulled the time from that server yet. Look in your logs for errors from the NTP binding.

Keep in mind that the NTP binding will not work well for you if your OH server is not connected to the Internet. If will grab the time while it is not connected to the Internet then it gets an error when it tries to pull the time again and result in an undefined Item. And because all it does is update the value of an Item it only works when the binding can reach the NTP server.

There is no internal clock to OH that the NTP binding updates. OH uses the system clock for its purposes. The NTP binding only updates the value of Items bound to it. It does not change the time OH uses internally nor does it update your system’s time.

Yes, all right. This indication appears when I disabled Internet. When I connected to Internet again, OH In a minute shows the time, but for one hour to be more than. In system time is correct. And time zone too.
In 2015 year in Russia changed the time zone. Earlier in Moscow it was (+4). Now (+3).
I think that the problem is that binding.ntp uses the server whose incorrect time zones. Is it possible?

That is very possible. You can point it to any NTP server you want to. Add ntp:hostname=<url> to openhab.cfg where <url> is the host name of an NTP server. You can search the Internet for publicly available NTP servers. IF you can find one hosted in Russia it might work better for you.

Nothing succeeded.
I tried 5 different NTP servers. Same result. Time in OH always for one hour to be more than.
Reconfigured in Raspbian time settings again anew. Checked the time zone, (+3), all right, time in system correct, but in OH does not.

Have same problem. In logs
2017-11-27 18:17:50.188 [ItemStateChangedEvent ] - Sk2_LastUpdate changed from 2017-11-27T18:16:50.155+0400 to 2017-11-27T18:17:50.155+0400
where i can edit this +400. I think its 4 hour, moscow timezone +3 hour,
try this manual
http://docs.openhab.org/addons/bindings/ntp/readme.html
not working

Could you please post your:

  • ntp.cfg (if you have one)
  • *.things with your ntp:ntp: thing
  • *.items with your item

And then, please also provide the time from the system:

  • Linux: date
  • Windows: w32tm /tz

oh2 dont have ntp.cfg, i think
thing
ntp:ntp:demo [ hostname=“0.ru.pool.ntp.org”, refreshInterval=60, refreshNtp=30 ]

its ru ntp, i try ntp,local too

.items
DateTime Date “Date [%1$tA, %1$td.%1$tm.%1$tY %1$tH:%1$tM]” { channel=“ntp:ntp:demo:dateTime” }
linux
pi@raspberrypi:~ $ date
Mon 27 Nov 18:59:06 MSK 2017
pi@raspberrypi:~ $ cat /etc/timezone
Europe/Moscow

oh2 event log

2017-11-27 18:52:41.765 [hingStatusInfoChangedEvent] - 'ntp:ntp:demo' changed from ONLINE to UNINITIALIZED
2017-11-27 18:52:42.473 [hingStatusInfoChangedEvent] - 'ntp:ntp:demo' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)
2017-11-27 18:52:46.830 [temChannelLinkRemovedEvent] - Link 'devrm_d => exec:command:devrm_d:run' has been removed.
2017-11-27 18:52:46.835 [temChannelLinkRemovedEvent] - Link 'devrm_a => exec:command:devrm_a:run' has been removed.
2017-11-27 18:52:46.840 [temChannelLinkRemovedEvent] - Link 'Sk2_LastUpdate => ntp:ntp:local:dateTime' has been removed.
2017-11-27 18:52:46.845 [temChannelLinkRemovedEvent] - Link 'Date => ntp:ntp:demo:dateTime' has been removed.
2017-11-27 18:52:46.880 [ThingRemovedEvent         ] - Thing 'ntp:ntp:demo' has been removed.
2017-11-27 18:58:16.399 [ItemChannelLinkAddedEvent ] - Link 'devrm_a-exec:command:devrm_a:run' has been added.
2017-11-27 18:58:16.406 [ItemChannelLinkAddedEvent ] - Link 'devrm_d-exec:command:devrm_d:run' has been added.
2017-11-27 18:58:16.416 [ItemChannelLinkAddedEvent ] - Link 'Sk2_LastUpdate-ntp:ntp:local:dateTime' has been added.
2017-11-27 18:58:16.425 [ItemChannelLinkAddedEvent ] - Link 'Date-ntp:ntp:demo:dateTime' has been added.
2017-11-27 18:58:48.985 [ItemStateChangedEvent     ] - Sk1_power_reachable changed from NULL to Offline
2017-11-27 18:58:49.005 [ItemStateChangedEvent     ] - Sk2_power_reachable changed from NULL to Online
2017-11-27 18:58:58.183 [ThingAddedEvent           ] - Thing 'ntp:ntp:demo' has been added.
2017-11-27 18:58:58.310 [hingStatusInfoChangedEvent] - 'ntp:ntp:demo' changed from UNINITIALIZED to INITIALIZING
2017-11-27 18:59:03.466 [hingStatusInfoChangedEvent] - 'ntp:ntp:demo' changed from INITIALIZING to ONLINE
2017-11-27 18:59:03.593 [ItemStateChangedEvent     ] - Date changed from 2017-11-27T18:59:03.433+0400 to 2017-11-27T18:59:03.408+0400
2017-11-27 18:59:03.597 [ItemStateChangedEvent     ] - Date changed from NULL to 2017-11-27T18:59:03.433+0400

it`s old log, write at 1 hour ago)
after all i try edit addons.cfg
A comma-separated list of bindings to install (e.g. “sonos,knx,zwave”)
binding = ntp

runtime.cfg
org.eclipse.smarthome.core.localeprovider:region= RU
don`t help.

For think. i have script witch run at 15:30 on Moscow and stop at 15:35 . He work pretty well at time. I think in oh dont change timezone for russia couse 2 more years ago russia canсel winter time

So - that’s the system date, it’s set to Moscow Standard Time, which is UTC+3.
If 18.59 was the correct time at you wrote it (I guess, because it fits! :wink: ), then this one is ok!
So, the times in the log are correct also - but you said, there old one? so it should read 17:59:03 in the last lines?

So, this means, OH2 time is 1hour off? You said, Russia canceled daylight savings time in 2015? So it used to be UTC+2 in November until then… I don’t know, how OH2 handles time internally, but perhaps there’s a bug in OH2 concerning DST in Moscow…?

but please try this one in your Thing configuration:
adding timeZone (it should use system’s timezone, but it’s worth a try)

ntp:ntp:demo [ hostname=“0.ru.pool.ntp.org”, timeZone="MSK", refreshInterval=60, refreshNtp=30 ]

system
pi@raspberrypi:~ $ date
Mon 27 Nov 19:42:55 MSK 2017
log

2017-11-27 20:39:48.355 [ItemStateChangedEvent     ] - Sk2_LastUpdate changed from 2017-11-27T20:34:48.010+0400 to 2017-11-27T20:39:48.290+0400
2017-11-27 20:39:58.391 [ItemStateChangedEvent     ] - Date changed from 2017-11-27T20:38:58.318+0400 to 2017-11-27T20:39:58.318+0400
2017-11-27 20:40:58.390 [ItemStateChangedEvent     ] - Date changed from 2017-11-27T20:39:58.318+0400 to 2017-11-27T20:40:58.318+0400
2017-11-27 20:41:58.390 [ItemStateChangedEvent     ] - Date changed from 2017-11-27T20:40:58.318+0400 to 2017-11-27T20:41:58.318+0400
2017-11-27 20:42:58.391 [ItemStateChangedEvent     ] - Date changed from 2017-11-27T20:41:58.318+0400 to 2017-11-27T20:42:58.318+0400

i find that

runtime\system\joda-time\joda-time\2.2\joda-time-2.2.jar
org/joda/time/tz/data/Europe/MoscowPK
cant decompile Moscow.class, think bug in this librarry
may be i dont rights and its old library

time don`t change

i think developer can update joda librarry

For our Russia tenant we are using "Europe/Moscow" timezone. But we are getting time with 1 hour ahead of the correct time.

Europe/Moscow is UTC+3 hours. But when I am print date formated with Europe/Moscow timezone getting 1 hour ahead of the correct time.

you can use the joda-time api, version need greater than 2.5.because joda-time api update the timezone db after Russian time zone change from version 2.5.
1 Like

Yes, seems that is the Problem - perhaps it’s an old or corrupt library and since tells the wrong calculations.

It seems so, yes! I’m not a developer and I don’t know, whether this is a problem of openHAB or Eclipse Smarthome? Does anyone know? @Kai? :wink:

Hi my problem, ntp does not work when it changes to raspberry localete. New localete tr_TR.UTF-8 does not work. en_GB.UTF-8 works when I do. What could be the reason? I’m waiting for your help.

home.things

ntp:ntp:local [hostname="0.tr.pool.ntp.org", refreshInterval=10, refreshNtp=30, locale="tr_TR.UTF-8", timeZone="Europe/Istanbul"]

home.items

DateTime Date "Date and Time: [%1$td.%1$tm.%1$tY %1$tH:%1$tM]" {channel="ntp:ntp:local:dateTime" }

home.sitemap

  Text item=Date icon="time" valuecolor=["black"]

it could be a bug in the NTP binding. Is there anything more in openhab.log?

Have you tried to set your default locale in PaperUI -> Configuration -> System -> Regional Settings to see if the default works ok?
If you don’t specify the locale within the NTP thing config, it will pull the OH2 default.

(minor) Note: You are grabbing the time from 0.tr.pool.ntp.org, not the local system time so there might be a difference in time between your local system time and that remote NTP server (if you are not synchronizing your local system with that NTP server).
You may want to rename your thing to ntp:ntp:remote or setup a local NTP server on your host and synch it with the remote, then put the thing to talk to your local NTP (hostname="127.0.0.1")