Having had surprisingly many power outages in the past few weeks I've noticed that the OpenEVSE won't resync the time after the power returns. Whether this is because it syncs at a much later time and I'm too impatient, I don't know.
If (as long as time sync is set to "automatic" the charger resynchronised it's time every day at 12:05am, it would mean that five minutes after power-up (when it'll have gone back to midnight at whatever date it says it is, I can't remember) it'll resynchronise. Perhaps this would even go so far as to render the backup battery redundant?
The current sync uses the browser clock, so it can only happen if you log into the station. We are working on Network Time sync which will sync automatically and make the clock chip and backup battery unnecessary.
Wow, I hadn't even considered it was done through the browser, even though I've seen that before (Dedicated Micros and I think Hikvision CCTV recorders have this option alongside NTP).
I might look at sending a RAPI event from my Domoticz server (which amongst other things monitors a UPS) to send a $S1 time sync every 24 hours and also following a period where the mains input voltage has dropped to zero.
Of course I could just buy a battery but where's the fun in that? :)
Okay, here we go. This has been tested on a Raspberry Pi 4 running the latest Raspbian, I'd expect it to work on any other Linux-based OS.
Create evseclock.sh in your home folder or whatever, containing the following:-
#!/bin/bash # ========================================================= # OpenEVSE clock sync script # ========================================================= # Settings EVSE_IP="192.168.***.***" # OpenEVSE IP Address EVSE_USERNAME="admin" # OpenEVSE Username EVSE_PASSWORD="*****" # OpenEVSE Password # Create URL EVSEURL="http://$EVSE_IP/r?json=1&rapi=\$S1%20`date +"%y%%20%m%%20%d%%20%H%%20%M%%20%S"`" echo "$EVSEURL" # Run the RAPI command curl --digest --user "$EVSE_USERNAME:$EVSE_PASSWORD" "$EVSEURL"
Edit permissions with chmod 755 evseclock.sh
Finally put the following in your crontab using sudo crontab -e, change the time (in this case every 5 minutes) and file path to suit:-
*/5 * * * * /home/pi/evseclock.sh >/dev/null 2>&1
The echo "$EVSEURL" line can be removed from the script, it was in there for testing.
(I can't edit the above post)