ebaauw / homebridge-rpi

Homebridge plugin for Raspberry Pi.
Apache License 2.0
309 stars 19 forks source link

Time in iOS is off #100

Closed mhin76 closed 3 years ago

mhin76 commented 3 years ago

I just enabled to GPIO input as contact sensors and all works fine in displaying them on my iPhone. However the timing is very strangely off. One contact is off by 53min, the other by about 30min. Means, when I open/close the contact it shows correctly in the EVE app, but the history shows it 53min earlier. Also the "last opened" shows "before 1h". On my raspberry the time is displayed correctly. I rebooted the system couple of times. No improvement. I also saw on the homebrige log that it sets the "last activation" value quite hight: [18.6.2021, 16:43:48] [RPi] HA Watering: set Contact Sensor State from 0 to 1 [18.6.2021, 16:43:48] [RPi] HA Watering: set Times Opened from 32 to 33 [18.6.2021, 16:43:48] [RPi] HA Watering: set Last Activation from 9518 seconds to 10655 seconds [18.6.2021, 16:43:52] [RPi] HA Watering: set Contact Sensor State from 1 to 0 [18.6.2021, 16:43:52] [RPi] HA Watering: set Last Activation from 10655 seconds to 10660 seconds (This one is showing in my iOS as 15:51, open for 5 second).

Do I miss anything?

ebaauw commented 3 years ago

I have never seen this before, but I suppose it could happen when Homebridge is first started when the system clock is off. I would try a Reset Count in Eve, under the i under Times Opened. That should resync the history reference time. If that doesn’t work, try removing the cached accessory using the Homebridge UI. That should delete the entire history and restart it from scratch.

To prevent this from happening again, make sure the system clock is correct before starting Homebridge. I use ntp to sync the clock and set the RPi to wait for the network on boot, so Homebridge won’t start before ntp had a chance to sync the clock. If you run without an Internet connection, consider a real-time clock

mhin76 commented 3 years ago

Thanks for fast reply. Will test the reset. Strange thing is that those two contacts are differently off. Will let you know about further findings.

mhin76 commented 3 years ago

You are a genius!! Resetting via Eve app worked! Timing now is accurate. I would have never guessed this approach! thanks a lot!