Support use an expression as paramter in some rule commands, include Var<x>, Mem<x> and Ruletimer<x>.
Expression is constructed by constants (float number), variables (var<x>, mem<x>, Time, Uptime, Sunrise, Sunset), operators and round brackets.
Currently support 6 operators, order by priority from high to low:
^ (power)
% (modulo)
*, /
+, -
Commands examples:
Var1 3.14 * (MEM1 * (10 + VAR2 ^2) - 100) % 10 + uptime / (2 + MEM2)
Ruletimer4 Time - Sunrise + MEM2/2
Introduce new compare operators for rules and did some optimization as well.
The new "==" operator act as a real number comparison instead of the previous "=" operator which is doing string comparison which result in FALSE for "1 + 1 = 2". For example:
rule1 on event#test do backlog var1 1;add1 1; event CompareWith2=2 endon on event#CompareWith2=%var1% do ledpower on endon
ledpower off
rule1 on
event test
Added new triggers for rules: `VARx#STATE` and `MEMx#STATE`
These new triggers allows to execute commands when VARs or MEMs change their values.
This is useful for automations where the parameter sent to Tasmota by MQTT is a SetPoint for example.
Before these triggers, the approach was using an `EVENT` to store a value but some components in home automation softwares can't use `cmnd/sonofftopic/EVENT SETVAR=25`, where `cmnd/sonofftopic/EVENT` is the mqtt message and `SETVAR=25` is the payload.
With this new triggers, it will be as simple as `cmnd/sonofftopic/VAR 25` so any automation software can use it.
_(Using `cmnd/sonofftopic/EVENT SETVAR=` as mqtt message and `25` as payload is not understood by Tasmota)_
6.4.1.2 20181228
* Change switch driver making it modular and introduce input filter (#4665, #4724)
* Add define DS18B20_INTERNAL_PULLUP to select internal input pullup when only one DS18B20 sensor is connected eliminating external resistor (#4738)
* Add variable %timestamp% to rules (#4749)
This PR adds a new variable %timestamp% to be used in a rule to allow the user to include the Time Stamp as Tasmota has for Status, Sensors, etc, for example:
Command:
publish stat/topic/sensor {"Time":"%timestamp%","mysensor":"%var1%"}
Output:
{"Time":"2018-12-27T12:52:57","mysensor":"1"}
(https://github.com/arendst/Sonoff-Tasmota/issues/4734)
RULES: Added BREAK as an alternative ENDON that will stop the execution of the following rules.
If a rule that ends with BREAK, is triggered, then the following rules of that set will not be executed. This is useful for cases like: https://github.com/arendst/Sonoff-Tasmota/issues/4477
To make it possible to trigger a rule at boot time with the state of the switches or relays (in order to take decisions), 2 new trigger types has been added:
* SWITCH1#BOOT
to be used like:
ON SWITCH1#BOOT DO ... %value% ENDON
ON SWITCH1#BOOT=0 DO .... ENDON
ON SWITCH1#BOOT=1 DO .... ENDON
and
* POWER1#BOOT
to be used like:
ON POWER1#BOOT DO ... %value% ENDON
ON POWER1#BOOT=0 DO .... ENDON
ON POWER1#BOOT=1 DO .... ENDON
* Change pinmode for no-pullup defined switches to pullup when configured as switchmode PUSHBUTTON (=3 and up) (#3896)
* Add delay after restart before processing rule sensor data (#3811)
6.2.1.3 20180907
* Change web Configure Module GPIO drop down list order for better readability
* Fix showing Period Power in energy threshold messages
* Fix ButtonRetain to not use default topic for clearing retain messages (#3737)
* Add optional MQTT_TELE_RETAIN to Energy Margins message (#3612, 3614)
* Add Individual HSBColorX commands (#3430, #3615)
* Add RuleX debug options 8,9,10 (StopOnError) to control RuleX execution status after an exception restart (#3607)
Added %sunrise%, %sunset%, %uptime% and %time% to be used in rules comparison like:
on Time#Initialized do backlog event checksunrise=%time%; event checksunset=%time% endon
on event#checksunset>%sunset% do power3 1 endon
on event#checksunrise<%sunrise% do power3 1 endon
6.1.1.9
* Allow user override of define MAX_RULE_TIMERS (#3561)
* Allow user override of define MAX_RULE_VARS
* Add GPIO options ButtonXn, SwitchXn and CounterXn to select INPUT mode instead of INPUT_PULLUP (#2525)
* Fix OtaMagic when file path contains a dash (-) (#3563)
6.0.0a
* Add time in minutes to rule Time#Initialized, Time#set and Time#Minute
(#2669)
* Add rule variables %time% for minutes since midnight, %uptime%,
%sunrise% and %sunset% giving time in minutes (#2669)
New Arithmetic commands to be used with VARs:
ADD1 to ADD5: Add a value to VAR[x]
Usage: ADD1 15
Result: VAR1 = VAR1 + 15
SUB1 to SUB5: Substract a value from VAR[x]
Usage: SUB1 15
Result: VAR1 = VAR1 - 15
MULT1 to MULT5: Multiply a value to VAR[x]
Usage: MULT1 15
Result: VAR1 = VAR1 * 15
SCALE1 to SCALE5: Scale a value from a low and high limit to another low and high limit and store it in VAR[x] (directly equivalent to MAP arduino command)
Syntax:
SCALEx value, fromLow, fromHigh, toLow, toHigh
Parameters
value: the number to scale
fromLow: the lower bound of the value’s current range
fromHigh: the upper bound of the value’s current range
toLow: the lower bound of the value’s target range
toHigh: the upper bound of the value’s target range
(omitted values are taken as zero)
Usage: SCALE1 15, 0, 100, 0, 1000
Result: VAR1 = 150
6.0.0a
* Add support for uploading Sonoff Bridge firmware found in
tools/fw_efm8bb1 folder build by Portisch using Web Gui File Upload
(#2886)
* Add command RfRaw to control Portisch firmware features