Skip to content

Commit 89a2e15

Browse files
authored
Merge pull request wled#1302 from catlee/nightlight-remaining
Return remaining nightlight time in json API
2 parents 99b1282 + 8d318e7 commit 89a2e15

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

wled00/json.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,20 @@ void serializeState(JsonObject root)
318318
nl[F("fade")] = (nightlightMode > NL_MODE_SET); //deprecated
319319
nl[F("mode")] = nightlightMode;
320320
nl[F("tbri")] = nightlightTargetBri;
321-
321+
if (nightlightActive) {
322+
nl[F("rem")] = (nightlightDelayMs - (millis() - nightlightStartTime)) / 1000; // seconds remaining
323+
} else {
324+
nl[F("rem")] = -1;
325+
}
326+
322327
JsonObject udpn = root.createNestedObject("udpn");
323328
udpn[F("send")] = notifyDirect;
324329
udpn[F("recv")] = receiveNotifications;
325330

326331
root[F("lor")] = realtimeOverride;
327332

328333
root[F("mainseg")] = strip.getMainSegmentId();
329-
334+
330335
JsonArray seg = root.createNestedArray("seg");
331336
for (byte s = 0; s < strip.getMaxSegments(); s++)
332337
{

0 commit comments

Comments
 (0)