* Add rule Http#Initialized
* Add command WebColor to change non-persistent GUI colors on the fly
Use a rule like:
rule3 on http#initialized do webcolor {"webcolor":["#eeeeee","#181818","#4f4f4f","#000000","#dddddd","#008000","#222222","#ff0000","#008000","#ffffff","#1fa3ec","#0e70a4","#d43535","#931f1f","#47c266","#5aaf6f","#ffffff","#999999","#000000"]} endon
or
rule3 on http#initialized do webcolor {"webcolor":["#eee","#181818","#4f4f4f","#000","#ddd","#008000","#222"]} endon
to make color changes persistent)
Support subscribe/unsubscribe MQTT topics and trigger specified event with the subscribed MQTT topic.
You can subscribe a MQTT topic and assign an event name. Once we received subscribed MQTT message, an event will be automatically triggered. So you can set up a rule with "ON EVENT#<event_name> DO ..." to do whatever you want based on this MQTT message. The payload is passed as a parameter once the event been triggered. If the payload is in JSON format, you are able to get the value of specified key as parameter.
For example, if you have a Tasmota based thermostat and multiple temperature sensors in different place, usually you have to set up a centre home automation system like Domoticz to control the thermostat. Right now, with this new feature, you can write a rule to do this.
Two new commands in Rules:
1. Subscribe
Subscribe a MQTT topic (with or without key) and assign an event name to it.
Command format:
Subscribe [<event_name>, <topic> [, <key>]]
This command will subscribe a <topic> and give it an event name <event_name>.
The optional parameter <key> is for parse the specified key/value from MQTT message
payload with JSON format.
In order to parse value from two level JSON data, you can use one dot (".") to split the key into two section.
Subscribe command without any parameter will list all topics currently subscribed.
2. Unsubscribe
Unsubscribe specified MQTT event.
Command format:
Unsubscribe [<event_name>]
Unsubscribe a topic subscribed by specify the event name.
If no event specified, Unsubscribe all topics subscribed.
Examples:
1.
Subscribe BkLight, Tasmota/BackyardLight/stat/POWER
And define a rule like:
Rule1 on event#BkLight=ON do ruletimer4 60 endon
2.
Subscribe DnTemp, Tasmota/RoomSensor1/stat/SENSOR, DS18B20.Temperature
Define a rule to deal with the MQTT message like {"Time":"2017-02-16T10:13:52", "DS18B20":{"Temperature":20.6}}
Rule1 ON EVENT#DnTemp>=21 DO ... ENDON
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)