esp8266-react icon indicating copy to clipboard operation
esp8266-react copied to clipboard

Setting Local Time Manually

Open tichaonax opened this issue 4 years ago • 8 comments

This is something really important especially for my application. Where internet is intermittent or non existent the device Access Point is good enough to operate the device. Ability to set local time becomes critically important. At the moment I hot-spot to my cell phone then once the schedules are set the device is good to go as long as the device is not reset.

tichaonax avatar Jun 13 '20 23:06 tichaonax

Thx. Yes, this is a missing feature - will get this implement this week.

rjwats avatar Jun 15 '20 14:06 rjwats

PR needs a review and a tidyup tomorrow. Looks decent though:

image

image

rjwats avatar Jun 15 '20 23:06 rjwats

NB - using browser "datetime-local" editor support rather than the MUI pickers to save space on the device. This is also up for review but i think the MUI date pickers are probably a little too large (18k minzipped) to include for this feature.

rjwats avatar Jun 15 '20 23:06 rjwats

I wanted to say we got hit by bad cold front Sunday night and went without electricity or wifi for more than 72 hours. Since NTP was inactive, I was not able to setup as the setup button did not get enabled. I tried to disable NTP service but it did not show. My esp8266 were connected to a router that did not have an uplink. Local network worked. What are the exact conditions under which the set-time button is enabled.

tichaonax avatar Feb 18 '21 00:02 tichaonax

It uses the underlying sntp_enabled flag to determine whether or not to allow the user to set the time manually - which seems to make sense is suppose because otherwise the manually set time would be overridden by the next NTP sync event.

Whenever the device is disconnected from WiFi, or if NTP is explicitly disabled it should become automatically available. But of course if ntp is not being correctly disabled by the SettingsService code this could fail... Here are some of the important bits:

image image image

(And basically the whole of NTPSettingsService)

Can you re-produce the problem with a series of steps I can re-create here?

rjwats avatar Feb 18 '21 09:02 rjwats

Sorry in delaying my response. You are right it did show the set time button but l needed to disable ntp first. I guess my situation was a bit different l was expecting the button to be enabled for a situation like what happened to me.. Having the ntp override my time is actually preferred in my case but l may just want to set the time if ntp is not available for whatever reason but might be available later. My systems will not enter their routines until a valid date time. I think having the button enabled all the time is fine it will still work for those who have ntp disabled and if l do not want override then l can disable ntp altogether but to only allow set time when ntp is disabled would be a loss of functionality l think. Otherwise it is wolike you said.

tichaonax avatar Feb 26 '21 02:02 tichaonax

The steps to reproduce would be. Have the esp device connected to wifi router. Disable the router uplink and reset the esp device. Ensure esp device still connected to wifi, If the ntp is enabled the set time won't show. I expected the button to show l think in my case l want it enabled all the time.

tichaonax avatar Feb 26 '21 03:02 tichaonax

Yeah, I follow what you're suggesting and it's a bit of an edge-case but I suppose still valid.

I guess there's no harm in enabling the set time feature at all times (could remove the check in the UI yourself). If making this change for everyone I'd put a warning in the dialog if NTP is enabled to say somthing like: "NTP is enabled, the set time you are setting will be overwritten when NTP next synchronises"

rjwats avatar Mar 18 '22 08:03 rjwats