Skip to content

Commit

Permalink
Merge pull request arendst#4749 from ascillato/patch-1
Browse files Browse the repository at this point in the history
Add variable %timestamp% to be used in rules
  • Loading branch information
arendst authored Dec 27, 2018
2 parents 7a18932 + 7eb2f58 commit 100ef0b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sonoff/xdrv_10_rules.ino
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ bool RulesRuleMatch(byte rule_set, String &event, String &rule)
if (rule_param.startsWith(stemp)) {
rule_param = String(GetMinutesUptime());
}
snprintf_P(stemp, sizeof(stemp), PSTR("%%TIMESTAMP%%"));
if (rule_param.startsWith(stemp)) {
rule_param = GetDateAndTime(DT_LOCAL).c_str();
}
#if defined(USE_TIMERS) && defined(USE_SUNRISE)
snprintf_P(stemp, sizeof(stemp), PSTR("%%SUNRISE%%"));
if (rule_param.startsWith(stemp)) {
Expand Down Expand Up @@ -313,6 +317,7 @@ bool RuleSetProcess(byte rule_set, String &event_saved)
}
commands.replace(F("%time%"), String(GetMinutesPastMidnight()));
commands.replace(F("%uptime%"), String(GetMinutesUptime()));
commands.replace(F("%timestamp%"), GetDateAndTime(DT_LOCAL).c_str());
#if defined(USE_TIMERS) && defined(USE_SUNRISE)
commands.replace(F("%sunrise%"), String(GetSunMinutes(0)));
commands.replace(F("%sunset%"), String(GetSunMinutes(1)));
Expand Down

0 comments on commit 100ef0b

Please sign in to comment.