OpenHAB 2 Wrong time after power failure

Hi.
I am using OpenHAB 2.1.0-1 on RPI2.

After a power failure in the whole house, the Time and Date gets confused! That is, totally wrong.

When I do a normal reboot or power OFF/ON cycle, the date is set correctly.

I believe, the problem is, when OpenHAB wakes up after a power failure, the internet connection is not yet available and the time does not get set.
I would expect the system to retry this more than once? Or it doesn’t?

Any idea on how to overcome this issue?

Thank you!

The Raspberry Pi doesn’t have a battery for some kind of hardware clock (like PCs or Laptops have). That’s why, after disconnection the PI from power (not only power failure, but simply pulling the USB-plug), the PI boots without a time.

I’m curious, because normally the PI distributions always come with an NTP preconfigured, because of this!
So, “totally wrong” means the time has an offset of some hours? or is it some time around 1970?

if it’s only off for some hours, your timezone is not configured, and you should go like this:

  1. sudo raspi-config
  2. Select Internationalisation Options
  3. Select I2 Change Timezone
  4. Select your Geographical Area
  5. Select your nearest City
  6. Select Finish
  7. Select Yes to reboot now

So, if it doesn’t update, you need to install the NTP Client.
If you don’t use openHABian (which is a pretty perfect solution for running OH2 on a PI and comes also preconfigured with a NTP client), you must configure NTP for yourself (depending on the distro).
For the Raspbian distro it’s pretty straight forward:

  • sudo apt-get install ntp
    that’s it - you don’t need to do anything more.

But if you have an NTP Server in your home and would like to use this one (FritzBox! for example), you can do that:

  • sudo nano /etc/ntp.conf

in there you can then edit the servers or add yours - and your PI should have the right time from now on.

Hi!
Yes, I am using Openhabian, and as far as I know NTP is/should be running.

By “totally wrong”, I meant it was not off only by hours (timezone problem), but also by minutes and seconds. That is the strange part.

After calling the sudo ntpd -gq, the time was corrected OK!

How often is time synced. I found and fixed this in about 6 hours.

The NTP daemon handles the update cycle for itself. There’s no need to define the cycle, so probaly your timeservers are not located ideally for your location.
You can pick your nearest here: http://support.ntp.org/bin/view/Servers/NTPPoolServers and change it in /etc/ntp.conf as described above.


If you still feel the need to configure the cycle for yourself, you can use the minpol and maxpol Setting in /etc/ntp.conf as described in man ntp.conf:

   minpoll minpoll, maxpoll maxpoll
          These options specify the minimum and maximum poll intervals for
          NTP messages, in seconds as a power of two.   The  maximum  poll
          interval  defaults  to 10 (1,024 s), but can be increased by the
          maxpoll option to an upper limit of 17 (36.4  h).   The  minimum
          poll  interval defaults to 6 (64 s), but can be decreased by the
          minpoll option to a lower limit of 4 (16 s).  These  option  are
          valid only with the server and peer commands.
1 Like

Thank you for your help. I changed the servers, but I’m not sure it will change anything.

From your post, the timeouts are way lower than 6 hours, so the clock should get fixed, but it somehow didn’t. I will try to reproduce the problem.