From 6f2f0b6feae018ef1414fbbae3bac4e2586d999f Mon Sep 17 00:00:00 2001 From: Laurent <44267323+laurentdong@users.noreply.github.com> Date: Mon, 18 Feb 2019 16:17:32 -0500 Subject: [PATCH] Add two constant varibles in rules expression Add two variables: - UtcTime The number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT) - LocalTime Seconds passed after Jan 1, 1970 midnight base on current timezone and daylight saving setting. --- sonoff/support_rtc.ino | 5 +++++ sonoff/xdrv_10_rules.ino | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/sonoff/support_rtc.ino b/sonoff/support_rtc.ino index 5c9f9e2b4..71fe7220c 100644 --- a/sonoff/support_rtc.ino +++ b/sonoff/support_rtc.ino @@ -331,6 +331,11 @@ uint32_t LocalTime(void) return local_time; } +uint32_t UtcTime(void) +{ + return utc_time; +} + uint32_t Midnight(void) { return midnight; diff --git a/sonoff/xdrv_10_rules.ino b/sonoff/xdrv_10_rules.ino index 1e0c57ae6..1dfbb2a58 100644 --- a/sonoff/xdrv_10_rules.ino +++ b/sonoff/xdrv_10_rules.ino @@ -651,6 +651,10 @@ bool findNextVariableValue(char * &pVarname, double &value) value = GetMinutesPastMidnight(); } else if (sVarName.equals(F("UPTIME"))) { value = GetMinutesUptime(); + } else if (sVarName.equals(F("UTCTIME"))) { + value = UtcTime(); + } else if (sVarName.equals(F("LOCALTIME"))) { + value = LocalTime(); #if defined(USE_TIMERS) && defined(USE_SUNRISE) } else if (sVarName.equals(F("SUNRISE"))) { value = GetSunMinutes(0);