Add variables to rules

Add variables ``%power<1..28>%`` and  ``%switch<1..28>%`` to rules (#19331)
This commit is contained in:
Theo Arends 2023-08-17 15:34:13 +02:00
parent aa097e9034
commit b8804cf2a8
3 changed files with 14 additions and 0 deletions

View File

@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
## [13.1.0.1]
### Added
- Commands to allow setting of timeprop parameters (#19310)
- Variables ``%power<1..28>%`` and ``%switch<1..28>%`` to rules (#19331)
### Breaking Changed

View File

@ -112,6 +112,8 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
## Changelog v13.1.0.1
### Added
- Commands to allow setting of timeprop parameters [#19310](https://github.com/arendst/Tasmota/issues/19310)
- Variables ``%power<1..28>%`` and ``%switch<1..28>%`` to rules [#19331](https://github.com/arendst/Tasmota/issues/19331)
### Breaking Changed

View File

@ -793,6 +793,16 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
snprintf_P(stemp, sizeof(stemp), PSTR("%%MEM%d%%"), i +1);
RulesVarReplace(commands, stemp, SettingsText(SET_MEM1 +i));
}
for (uint32_t i = 0; i < TasmotaGlobal.devices_present; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%%POWER%d%%"), i +1);
RulesVarReplace(commands, stemp, String(bitRead(TasmotaGlobal.power, i)));
}
for (uint32_t i = 0; i < MAX_SWITCHES_SET; i++) {
if (SwitchUsed(i)) {
snprintf_P(stemp, sizeof(stemp), PSTR("%%SWITCH%d%%"), i +1);
RulesVarReplace(commands, stemp, String(SwitchState(i)));
}
}
RulesVarReplace(commands, F("%TIME%"), String(MinutesPastMidnight()));
RulesVarReplace(commands, F("%UTCTIME%"), String(UtcTime()));
RulesVarReplace(commands, F("%UPTIME%"), String(MinutesUptime()));