boblemaire / IoTaWatt

IoTaWatt Open WiFi Electric Energy Monitor
https://iotawatt.com
GNU General Public License v3.0
647 stars 179 forks source link

Use NTP server(s) specified by DHCP #204

Closed aceat64 closed 4 years ago

aceat64 commented 5 years ago

I'd like to put my IoTaWatt on a secured vlan with no access to the internet, but currently it requires access to an NTP server in order to ensure good timekeeping. If it can use DHCP Option 42, I could use my local NTP server instead of having to craft firewall rules. This could also be useful for "off-grid" installs.

Optionally, if there was a way to simply change the the NTP server that would work as well.

boblemaire commented 5 years ago

Quick look isn't promising for getting at DHCP options. That's all at a lower level. I can add the ability to specify the URL (or IP?) of the NTP server(s), but I will have to think on how to do that best. I'm trying to keep the UI simple - not present a lot of options that most folks don't understand. I'm also trying to avoid users editing the config file as blowing the json syntax causes a lot of headache. Thinking of adding a library where files can be added with these kinds of specifications. Bottom line is this will be at least a few months before it gets to a release. In the meantime, if so inclined, the name is hard-coded in timeservices.cpp so you could compile your own version of the firmware.

Tuckie commented 5 years ago

Just voicing my support for an option to set the NTP server. I have a similar setup where the device does not have direct access to the internet.

starwolf73 commented 5 years ago

Also voicing my support as all my IoT is on secure VLAN with no access to internet.

boblemaire commented 4 years ago

I do not see a way to get that from the ESP8266/arduino core services. If you know how to get the DHCP NTP name, please advise, otherwise will close this issue as unattainable.

Tuckie commented 4 years ago

What about just being able to specify the NTP server?

Jalle19 commented 4 years ago

You can probably work around it with NAT (e.g. https://www.google.com/amp/s/www.linuxincluded.com/ntp-server-ip-blacklisted-nat-redirection-ftw/amp/)

kockockockoc commented 4 years ago

@boblemaire, looks like this thread about esp8266/Arduino and "NTP servers over DHCP": https://github.com/esp8266/Arduino/issues/5681

UPD: this example worked for me (sntp_getserver() func): https://github.com/esp8266/Arduino/blob/master/libraries/esp8266/examples/NTP-TZ-DST/NTP-TZ-DST.ino

ccutrer commented 2 years ago

Another voice for at least manually specifying the NTP server. That seems much more attainable than getting at the DHCP option.