Skip to content
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

Add timestamp in MQTT shower message #1329

Closed
proddy opened this issue Oct 14, 2023 Discussed in #1328 · 6 comments
Closed

Add timestamp in MQTT shower message #1329

proddy opened this issue Oct 14, 2023 Discussed in #1328 · 6 comments
Labels
enhancement New feature or request
Milestone

Comments

@proddy
Copy link
Contributor

proddy commented Oct 14, 2023

From the discussion #1328 started by @sciurius

he said in HA we use the last-updated property of the sensor to determine the timestamp. Sometimes it's not accurate and would be nicer to add the timestamp to the shower_data MQTT payload which is persisted.

@proddy proddy added the enhancement New feature or request label Oct 14, 2023
@proddy
Copy link
Contributor Author

proddy commented Oct 14, 2023

@MichaelDvP said:

"If the esp32-RTC isproper set by NTP, thermostat or manual we can add it.
Do you need timestamp or a time-string (or both)? Of shower end or start/end?
e.g.

{"duration":600,
"timestamp": 1697294490,
"time":"2023-10-14T16:42:07"
}"

@proddy
Copy link
Contributor Author

proddy commented Oct 14, 2023

I think time in HH:MM:SS is universal and ok. It's just for displaying in the Home Assistant dashboard.

@sciurius
Copy link

A timestamp (seconds since epoch) would avoid timezone issues. Otherwise "2023-10-14T18:46:44+0200" is ok.

@proddy
Copy link
Contributor Author

proddy commented Oct 15, 2023

@MichaelDvP shall you add or I?

@MichaelDvP
Copy link
Contributor

For the publish it's only

                        time_t now = time(nullptr);
                        if (now > 1576800000) { // year 2020
                            doc["timestamp"] = now; // if needed
                            tm *   tm_ = localtime(&now);
                            char dt[25];
                            strftime(dt, sizeof(dt), "%FT%T%z", tm_);
                            doc["time"] = dt;
                        }

but for the HA config it's better you add it to test and choose the right types.

@proddy
Copy link
Contributor Author

proddy commented Oct 15, 2023

thanks, I'll add and do a PR now. Along with #1323

@proddy proddy added this to the v3.6.3 milestone Oct 15, 2023
proddy added a commit to proddy/EMS-ESP32 that referenced this issue Oct 15, 2023
@proddy proddy closed this as completed Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants