-
Notifications
You must be signed in to change notification settings - Fork 803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SYS] Add utc & unix timestamp options to SYStoMQTT and Sensor messages #1533
Conversation
Also I think we should call the NTP less frequently. |
That's strange.. it's working for me:
is the NTP server reachable by your ESP?
Totally agree on this point That said, are there already less frequently called routines? |
We don't have, but I'm interested in adding a second one for OTA update checks. Also if the timestamp is for people without a controller, should we publish a human readable format instead of ms. |
Wouldn't be a legible time format UTC, without having to set timezone and dst offsets, be more helpful as an immediately recognisable time stamp, without requiring the help of a time converter, especially without the help of a controller? |
That seems a good scenario with a comparable order of magnitude (even more so if it will be user-configurable)
Well.. I get your point, and I frankly I'm still undecided too, as similar projects are still divided on what's best.
while Shelly uses Unix time:
maybe the best approach could be to make the timestamp user-selectable, both for enable/disable and unix/ISO8601
what do you think? (@1technophile and @DigiH ) |
👍 from me! Best to also prefix a UTC, just to be totally clear. I don't think it would even have to be made user-selectable. The above is clearly legible by anyone at first sight, and can just as easily be converted to any other time format by a controller, as would unixtime. And users being able to read and understand unixtime on the spot - is it one minute ago, one hour, one day - are very few and far between ;) |
I like this also, and I don't think we need it to be changed by the user |
Add optional timestamps to the SYStoMQTT topic Also, the sync with the NTP time server now occurs every hour instead of every 2 minutes (can be defined with TimeBetweenCheckingSYS in UserConfig.h)
@1technophile : synced with dev branch and pushed the updated timestamp code, I commented the features in UserConfig.h, let me know if there's any other place where I should better explain (well, not that there's a lot to explain in a boolean option anyways :) @DigiH : to maintain compatibility with ISO8601 standard and still warn users that the time is UTC, the time string now ends with a capital Z, indicating that the time is UTC:
|
I already watched, and the Zulu time zone indicator is perfect and standard to mark the time stamp as UTC. The only possible other addition could be to rename the key to "utctime" (in coexistence with "unixtime") to also make it immediately clear for non-Z aware users, and to avoid future queries about it. |
that's actually a great idea! Committing it now :) |
also renamed the DEFINEs for better readability |
Thanks |
Thank you for OMQTTGateway, I'm happy to have had a chance to contribute :) |
Description:
(sorry, I removed previous pull request by mistake)
Sync to the defined NTP server and add unix timestamp to MQTTtoSYS topic and to all sensor messages.
(As discussed in #1404 )
In certain scenarios, (e.g. without an external controller and a database) it is impossible to know when a sensor reported a reading. (especially with retained messages)
Since most battery-powered sensors lack time information, the Gateway is the only point that can provide this data.
Checklist: