Return remaining nightlight time in json API
This returns the number of seconds remaining in the nightlight in the "rem" field of the nightlight ("nl") state. If there is no nightlight active, it returns -1.
This commit is contained in:
parent
b8fcab29ac
commit
8d318e7206
@ -318,6 +318,11 @@ void serializeState(JsonObject root)
|
|||||||
nl[F("fade")] = (nightlightMode > NL_MODE_SET); //deprecated
|
nl[F("fade")] = (nightlightMode > NL_MODE_SET); //deprecated
|
||||||
nl[F("mode")] = nightlightMode;
|
nl[F("mode")] = nightlightMode;
|
||||||
nl[F("tbri")] = nightlightTargetBri;
|
nl[F("tbri")] = nightlightTargetBri;
|
||||||
|
if (nightlightActive) {
|
||||||
|
nl[F("rem")] = (nightlightDelayMs - (millis() - nightlightStartTime)) / 1000; // seconds remaining
|
||||||
|
} else {
|
||||||
|
nl[F("rem")] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
JsonObject udpn = root.createNestedObject("udpn");
|
JsonObject udpn = root.createNestedObject("udpn");
|
||||||
udpn[F("send")] = notifyDirect;
|
udpn[F("send")] = notifyDirect;
|
||||||
|
Loading…
Reference in New Issue
Block a user