Skip to content

Commit

Permalink
Fix json status report (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewturner authored Dec 16, 2023
1 parent b6695d0 commit 168b796
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ void outputStatusAsJson(WiFiClient *pClient)
body += F("\"scheduleUpdatedAt\": ");
if (scheduleRetrieved)
{
unsigned long scheduleUpdatedAt = epochTime - (lastScheduleUpdate / 1000);
unsigned long lastScheduleUpdateAgoSeconds = (now - lastScheduleUpdate) / 1000;
unsigned long scheduleUpdatedAt = epochTime - lastScheduleUpdateAgoSeconds;
formatEpochAsUtc(buff, scheduleUpdatedAt);
body += F("\"");
body += String(buff);
Expand All @@ -278,14 +279,15 @@ void outputStatusAsJson(WiFiClient *pClient)
}
body += F(",\n");

body += F("\"timeSyncedAt\": ");
body += F("\"clockSyncedAt\": ");
if (lastSync == 0)
{
body += F("null");
}
else
{
unsigned long lastSyncedAt = epochTime - (lastSync / 1000);
unsigned long lastSyncAgoSeconds = (now - lastSync) / 1000;
unsigned long lastSyncedAt = epochTime - lastSyncAgoSeconds;
formatEpochAsUtc(buff, lastSyncedAt);
body += F("\"");
body += String(buff);
Expand Down

0 comments on commit 168b796

Please sign in to comment.