From 8bb562e880f4e4e1eb4ff0ec74f501034f045ba1 Mon Sep 17 00:00:00 2001 From: marsman7 Date: Mon, 14 Aug 2023 20:41:24 +0200 Subject: [PATCH 1/2] Creates a place to put the customer boards --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3a575e21aca8..82c56687b3bc 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ .cache data unpacked_fs +unpacked_boards tasmota/user_config_override.h build build_output/* From 24cecdf48437ede9330438eb25830062b01c0b90 Mon Sep 17 00:00:00 2001 From: marsman7 Date: Wed, 16 Aug 2023 20:32:21 +0200 Subject: [PATCH 2/2] Adds rule variable power and switch The variables can be used to query or logic operation of the current status of the inputs and outputs. For example, in a 3-sockets with USB output, the USB output can be switched on when one of the sockets is switched on: rule1 on power1#state do event usbpower endon on power2#state do event usbpower endon on power3#state do event usbpower endon rule2 on event#usbpower do if ( %power1%==1 or %power2%==1 or %power3%==1 ) power4 1 else power4 0 endif endon or if you want to send a message when the inputs have a defined status: rule3 on event#test do if ( %switch1%==1 and %switch2%==0 and %switch3%==1 ) publish stat/foo/bar hello endif endon To use the examples the feature #define USE_EXPRESSION and #define SUPPORT_IF_STATEMENT must compiled in. --- tasmota/tasmota_xdrv_driver/xdrv_10_rules.ino | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_10_rules.ino b/tasmota/tasmota_xdrv_driver/xdrv_10_rules.ino index 8fe9f2d50a33..2fa3435898b0 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_10_rules.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_10_rules.ino @@ -823,6 +823,15 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved) RulesVarReplace(commands, F("%ZBENDPOINT%"), String(Z_GetLastEndpoint())); #endif + for (uint32_t i = 0; i < MAX_RELAYS; 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++) { + snprintf_P(stemp, sizeof(stemp), PSTR("%%SWITCH%d%%"), i +1); + RulesVarReplace(commands, stemp, String(SwitchState(i))); + } + char command[commands.length() +1]; strlcpy(command, commands.c_str(), sizeof(command));