From ec045445e6456802967a7de8e40686bf6a775242 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 10 May 2020 14:39:13 +0200 Subject: [PATCH] Enable rule compression in my_user_config.h --- RELEASENOTES.md | 3 ++- tasmota/CHANGELOG.md | 3 ++- tasmota/my_user_config.h | 4 ++-- tasmota/xdrv_10_rules.ino | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 24e65e4b0..cd4f55cf1 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -82,6 +82,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c - Add command ``SetOption90 1`` to disable non-json MQTT messages (#8044) - Add command ``SetOption91 1`` to enable fading at startup / power on - Add command ``SetOption92 1`` to set PWM Mode from regular PWM to ColorTemp control (Xiaomi Philips ...) +- Add command ``SetOption93 1`` to control caching of compressed rules - Add command ``Sensor10 0/1/2`` to control BH1750 resolution - 0 = High (default), 1 = High2, 2 = Low (#8016) - Add command ``Sensor10 31..254`` to control BH1750 measurement time which defaults to 69 (#8016) - Add command ``Sensor18 0..32000`` to control PMS5003 sensor interval to extend lifetime by Gene Ruebsamen (#8128) @@ -103,5 +104,5 @@ The following binary downloads have been compiled with ESP8266/Arduino library c - Add support for OpenTherm by Yuriy Sannikov (#8373) - Add support for Thermostat control by arijav (#8212) - Add experimental basic support for Tasmota on ESP32 based on work by Jörg Schüler-Maroldt -- Add automatic compression of Rules to achieve ~60% compression, added ``SetOption93 1`` to control caching of rules +- Add automatic compression of Rules to achieve ~60% compression by Stefan Hadinger - Add rule trigger at root level like ``on loadavg<50 do power 2 endon`` after ``state`` command diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index a54809a68..aad27a856 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -6,7 +6,8 @@ - Add support for analog anemometer by Matteo Albinola (#8283) - Add support for OpenTherm by Yuriy Sannikov (#8373) - Add support for Thermostat control by arijav (#8212) -- Add automatic compression of Rules to achieve ~60% compression, added ``SetOption93 1`` to control caching of rules +- Add automatic compression of Rules to achieve ~60% compression by Stefan Hadinger +- Add command ``SetOption93 1`` to control caching of compressed rules - Add rule trigger at root level like ``on loadavg<50 do power 2 endon`` after ``state`` command - Change flash access removing support for any Core before 2.6.3 - Change HAss discovery by Federico Leoni (#8370) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index ce93a6eed..9af23d0b8 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -395,9 +395,9 @@ // #define USE_PING // Enable Ping command (+2k code) // -- Rules or Script ---------------------------- -// Select none or only one of the below defines +// Select none or only one of the below defines USE_RULES or USE_SCRIPT #define USE_RULES // Add support for rules (+8k code) - // #define USE_RULES_COMPRESSION // Compresses rules in Flash at about ~50% (+3.8k code) + #define USE_RULES_COMPRESSION // Compresses rules in Flash at about ~50% (+3.8k code) //#define USE_SCRIPT // Add support for script (+17k code) //#define USE_SCRIPT_FATFS 4 // Script: Add FAT FileSystem Support diff --git a/tasmota/xdrv_10_rules.ino b/tasmota/xdrv_10_rules.ino index f2f01a8db..33f61a68c 100644 --- a/tasmota/xdrv_10_rules.ino +++ b/tasmota/xdrv_10_rules.ino @@ -47,7 +47,7 @@ * on button1#state do publish cmnd/ring2/power %value% endon on button2#state do publish cmnd/strip1/power %value% endon * on switch1#state do power2 %value% endon * on analog#a0div10 do publish cmnd/ring2/dimmer %value% endon - * on root#loadavg<50 do power 2 endon + * on loadavg<50 do power 2 endon * * Notes: * Spaces after , around and before are mandatory @@ -203,7 +203,7 @@ char rules_vars[MAX_RULE_VARS][33] = {{ 0 }}; * Rule[x][0] = 0, if firmware is downgraded, the rule will be considered as empty * * The second byte contains the size of uncompressed rule in 8-bytes blocks (i.e. (len+7)/8 ) - * Maximum rule size si 2KB (2048 bytes per rule), although there is little chances compression ratio will go down to 75% + * Maximum rule size is 2KB (2048 bytes per rule), although there is little chances compression ratio will go down to 75% * Rule[x][1] = size uncompressed in dwords. If zero, the rule is empty. * * The remaining bytes contain the compressed rule, NULL terminated @@ -1987,7 +1987,7 @@ void CmndRule(void) } int32_t res = SetRule(index - 1, ('"' == XdrvMailbox.data[0]) ? "" : XdrvMailbox.data, append); if (res < 0) { - AddLog_P2(LOG_LEVEL_ERROR, PSTR("RUL: not enough space")); + AddLog_P2(LOG_LEVEL_ERROR, PSTR("RUL: Not enough space")); } } Rules.triggers[index -1] = 0; // Reset once flag