Skip to content

Commit

Permalink
add timestamp for RTL_433 messages
Browse files Browse the repository at this point in the history
- add timestamp when puglishing
- add "GMT" as timezone for timestamp
  • Loading branch information
dkneisz committed Jun 11, 2023
1 parent e27e055 commit ab69a2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions main/ZgatewayRTL_433.ino
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,15 @@ void rtl_433_Callback(char* message) {

uniqueid.replace("/", "-");

# if defined(ESP8266) || defined(ESP32)
# if message_UTCtimestamp == true
RFrtl_433_ESPdata["UTCtime"] = UTCtimestamp();
# endif
# if message_unixtimestamp == true
RFrtl_433_ESPdata["unixtime"] = unixtimestamp();
# endif
# endif

// Log.notice(F("uniqueid: %s" CR), uniqueid.c_str());
if (!isAduplicateSignal(MQTTvalue)) {
# ifdef ZmqttDiscovery
Expand Down
4 changes: 2 additions & 2 deletions main/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1953,8 +1953,8 @@ int unixtimestamp() {
String UTCtimestamp() {
time_t now;
time(&now);
char buffer[sizeof "yyyy-MM-ddThh:mm:ssZ"];
strftime(buffer, sizeof buffer, "%FT%TZ", gmtime(&now));
char buffer[sizeof "yyyy-MM-ddThh:mm:ssZGMT"];
strftime(buffer, sizeof buffer, "%FT%TZGMT", gmtime(&now));
return buffer;
}

Expand Down

0 comments on commit ab69a2b

Please sign in to comment.