Commit Graph

62 Commits

Author SHA1 Message Date
Theo Arends 14d5f7fb54 Fix GUI password and Add rule expression
* Fix GUI wifi password acception starting with asteriks (*) (#5231, #5242)
 * Add rule expression enabled  by define USE_EXPRESSION in my_user_config.h (#5210)
2019-02-16 16:17:17 +01:00
Laurent 4b4b3709ad Introduce Expression in Rules
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
2019-02-12 21:46:42 -05:00
Theo Arends ee2660b2bc Update xdrv_10_rules.ino
Move const to flash
2019-02-05 17:45:35 +01:00
Laurent Dong 09732c9f2d Add new compare operators ("==", "!=" ,">=" and "<=") for rule
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
2019-02-05 09:34:17 -05:00
Theo Arends 304ac6fe44 6.4.1.12 code changes (byte/boolean)
6.4.1.12 20190128
 * Change code use of boolean to bool and byte to uint8_t
 * Change code uint8_t flags to bool flags
2019-01-28 14:08:33 +01:00
Theo Arends 0186a97cb0 Fix allowable MAX_RULE_VARS to 16
Fix allowable MAX_RULE_VARS to 16 (#4933)
2019-01-15 16:30:20 +01:00
Adrian Scillato 1d23c0b0c5
New Triggers for Rules: VARx#STATE and MEMx#STATE
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)_
2019-01-04 16:26:37 -03:00
Theo Arends 447ec6256e 6.4.1.4 Update Copyright (C) 2019
6.4.1.4 20190101
 * Update Copyright (C) 2019
2019-01-01 13:55:01 +01:00
Theo Arends 5a44b12870 6.4.1.2 Rewrite Switch driver
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)
2018-12-28 16:35:19 +01:00
Adrian Scillato 4fcbaf99be
Add variable %timestamp% to be used in rules
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)
2018-12-27 14:57:27 -03:00
Theo Arends c1102a4863 6.4.0.2 Fix possible dtostrf bos
6.4.0.2 20181221
 * Fix possible dtostrf buffer overflows by increasing buffers
2018-12-21 16:17:06 +01:00
Adrian Scillato c68fe7e7ad
RULES: Added BREAK as an alternative ENDON 2018-12-01 19:00:34 -03:00
Adrian Scillato 7f2b3643f5
RULES: Added BREAK as an alternative ENDON
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
2018-12-01 18:12:33 -03:00
Adrian Scillato e3d1971e51
Add Command CalcRes 2018-11-26 23:08:23 -03:00
Adrian Scillato f7a8f39f89
Added command CalcRes 2018-11-26 21:22:44 -03:00
Erik bee50cba06 Add support for sensor discovery 2018-11-21 19:21:51 +01:00
andrethomas 4a7e7b0dbb Change C functions with () to (void) 2018-11-14 15:32:09 +02:00
Theo Arends 9fef82736d Prep drivers for management
Prep drivers for management
2018-11-07 10:30:03 +01:00
Adrian Scillato bcc9432214
Added Dimmer Trigger for Rules
For example

rule on Dimmer#state<30 do ... endon
rule on Dimmer#boot<10 do ... endon
2018-10-01 13:13:47 -03:00
Adrian Scillato a67efa0ab2
Added new triggers for rules on boot time
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
2018-09-26 23:02:55 -03:00
Theo Arends 6939d6eead Fix Shelly Ghost and Rule sensors
* 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)
2018-09-26 11:56:58 +02:00
Theo Arends 01ce1b0c91 Fix Shelly2 monitoring
Disable serial logging on Shelly2 as serial is being used by energy monitoring (#3878)
2018-09-23 13:55:42 +02:00
Theo Arends f05fc71d67 Fix rule trigger POWER1#STATE
Fix rule trigger POWER1#STATE execution after restart and SetOption0 is 0 (#3856)
2018-09-22 17:37:49 +02:00
Theo Arends 7cd9224819 6.2.1.3 - Change drop down list
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)
2018-09-08 17:18:31 +02:00
Theo Arends 55b43734d8 6.1.1.13 - Fixes
6.1.1.13 20180828
 * Fix 6.1.1.12 regression of Mem and Var default handling (#3618)
 * Optimizations
2018-08-28 11:10:32 +02:00
Theo Arends f8666c0410 Some requested additions
* 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)
2018-08-28 10:26:33 +02:00
Theo Arends d4931f7b11 Fix handling default names Pt.2
Fix handling default names Pt.2
2018-08-27 14:53:09 +02:00
Theo Arends 9978381c94 Fix handling deafult names
Fix handling use of default names when using names starting with shortcut character (#3392, #3600)
2018-08-27 13:06:22 +02:00
Adrian Scillato f70e4ab783
Added time parameters as variable comparison
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
2018-08-27 04:59:17 -03:00
Theo Arends bbd2529914 Sleep fixes part 2 and 3 of 3
* Change scheduler phase 2/3 - Fixed when sleep is enabled: Blinktime (#3581)
 * Change scheduler phase 3/3 - Some sensor update timings: AdcEvery 200 -> 250, Senseair 300 -> 250, SDM120 300 -> 250, SDM630 300 -> 250
2018-08-26 17:10:18 +02:00
Theo Arends f090050e69 6.1.1.11 - Sleep fixes part 1
6.1.1.11 20180826
 * Change scheduler phase 1 - Fixed when sleep is enabled: Uptime, Delay, PulseTime and TelePeriod (#3581)
2018-08-26 15:42:35 +02:00
Theo Arends b34874ba45 Add all ruletimer values
Add all ruletimer values to command RuleTimer result message (#3571)
2018-08-24 18:22:04 +02:00
Theo Arends 6a5c0d29e8 6.1.1.9 - Fixes and Additions
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)
2018-08-23 16:05:51 +02:00
Theo Arends 8a61c25218 6.1.1.6 Add modulo option to rules
Add modulo option to rules like rule1 on Time#Minute|5 do backlog power on;delay 200;power off endon (#3466)
2018-08-13 13:09:22 +02:00
Theo Arends cc5b0aaf90 Add option + to command Rule
Add option + to command Rule to concatenate new rule with existing rules (#3365)
2018-07-29 14:45:42 +02:00
Theo Arends da7dadae21 Add rule triggers
Add rule triggers Wifi#Connected and Wifi#Disconnected (#3359)
2018-07-28 15:06:31 +02:00
Adrian Scillato 96fb23737d
Move subStr Function to Support.ino 2018-07-23 01:29:50 -03:00
Theo Arends 9ef10f24d2 Fix command Scale buffer overflow
Fix command Scale buffer overflow (#3236)
2018-07-16 12:37:49 +02:00
Theo Arends b56961c528 Fix rules once regression
Fix rules once regression from v6.1.0 (#3198, #3226)
2018-07-16 11:34:44 +02:00
Adrian Scillato 27ddbb0609
Added decimal values support for commands ADD, SUB, MULT and SCALE 2018-06-28 13:06:21 -03:00
Theo Arends 20a53950ff Fix possible wifi connection problem
Fix possible wifi connection problem (#1366)
2018-06-28 12:25:50 +02:00
Theo Arends 862623b295 Add rule variables and add minutes
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)
2018-06-26 16:22:53 +02:00
Theo Arends dc1c2abda7 Add heap and stack debug information
Add heap and stack debug information
2018-06-26 11:48:09 +02:00
Theo Arends e818f0da55 Fix rules induced LWT message
Fix rules induced LWT message
2018-06-25 18:00:20 +02:00
Adrian Scillato f45dd53352
Add Arithmetic commands for VAR
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
2018-06-10 02:09:11 -03:00
Theo Arends d4119fe54d Add SnfBrdg EFM8BB1 fw tools
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
2018-06-04 18:10:38 +02:00
Theo Arends f3c4001b4a Fix HWRestart on rule event
5.14.0b
* Fix Hardware Watchdog restart when using event command (#2853)
2018-05-29 17:24:42 +02:00
Theo Arends ed56322f12 Add command source information
5.14.0b
* Add source information to command execution to be shown with logging
option 3 (#2843)
2018-05-28 15:52:42 +02:00
Theo Arends d1db31fc0a Fix rule string comparison 2018-05-24 17:08:14 +02:00
Theo Arends 9f329d5fb0 Add rule support for IrReceive and RfReceive
5.14.0b
 * Add rule support for IrReceive and RfReceive (#2758)
2018-05-24 16:23:20 +02:00