In case of a central power outage both internet router and domoticz are down.
When the power is back both internet router and domoticz are starting up and domoticz may start before internet is up and running.
In that case domoticz may start without successful time synchronization.
In order to give a chance to domoticz to start with a successful time synchronization i have updated domoticz.sh file in my system in such a way as to try a time synchronization every 30 second for 5 minutes. If the time synchronization is successful domoticz starts with a synchronized time. After the 5 minutes delay domoticz starts without successful time synchronization.
Current source code line 71 onwards:
Code: Select all
count=30
while [ ! -f "/run/systemd/timesync/synchronized" ]
do
count=$((count-1))
if [ $((count)) -lt 1 ]
then
# If failed, print error message, exit loop and start Domoticz anyway
printf "\nWARNING: Time synchronization failed, check network and /etc/systemd/timesyncd.conf\n"
printf "Starting Domoticz without successful time synchronization...\n"
break
fi
printf "."
sleep 1
done
Code: Select all
count=10
while [ ! -f "/run/systemd/timesync/synchronized" ]
do
count=$((count-1))
if [ $((count)) -lt 1 ]
then
# If failed, print error message, exit loop and start Domoticz anyway
printf "\nWARNING: Time synchronization failed, check network and /etc/systemd/timesyncd.conf\n"
printf "Starting Domoticz without successful time synchronization...\n"
break
fi
printf "\nRestart systemd-timesyncd for time synchronization...\n"
sudo systemctl restart systemd-timesyncd
sleep 30
done