Add NTP check every hour (ESP8266 RTC is BAD at keeping track of time)

This commit is contained in:
arofarn 2020-04-22 11:10:11 +02:00
parent 7ab1fd8fbb
commit 83d77277e7

View File

@ -239,3 +239,10 @@ while True:
if BRIGHTN_DATA is not None and time.ticks_diff(time.ticks_ms(), MQTT_TIMER) >= 0: if BRIGHTN_DATA is not None and time.ticks_diff(time.ticks_ms(), MQTT_TIMER) >= 0:
MqttMultiPublish(BRIGHTN_DATA) MqttMultiPublish(BRIGHTN_DATA)
BRIGHTN_DATA = None BRIGHTN_DATA = None
time_to_test = rtc.datetime()
if time_to_test[5] + time_to_test[6] == 0: # (chaque heure quand min et sec = 0)
print("Old Time: {0:04d}/{1:02d}/{2:02d}_{4:02d}:{5:02d}:{6:02d}.{7}".format(*time_to_test))
set_rtc()
print("Time set: {0:04d}/{1:02d}/{2:02d}_{4:02d}:{5:02d}:{6:02d}.{7}".format(*rtc.datetime()))