Update root level triggers

Add rule trigger ``#`` to trigger on any root value like ``on #loadavg<50 do power 2 endon`` after ``state`` command
This commit is contained in:
Theo Arends 2020-05-09 19:33:19 +02:00
parent 92c05faa8b
commit bf215b1b9d
3 changed files with 4 additions and 4 deletions

View File

@ -104,4 +104,4 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
- 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 rule trigger ``root#`` to trigger on any root value like ``on root#loadavg<50 do power 2 endon`` after ``state`` command
- Add rule trigger ``#`` to trigger on any root value like ``on #loadavg<50 do power 2 endon`` after ``state`` command

View File

@ -7,7 +7,7 @@
- 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 rule trigger ``root#`` to trigger on any root value like ``on root#loadavg<50 do power 2 endon`` after ``state`` command
- Add rule trigger ``#`` to trigger on any root value 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)
- Change default PWM Frequency to 977 Hz from 223 Hz

View File

@ -491,14 +491,14 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule)
rule_name = rule_name.substring(0, pos); // "SUBTYPE1#CURRENT"
}
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Find Task %s, Name %s"), rule_task.c_str(), rule_name.c_str());
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Find Task %s, Name %s"), rule_task.c_str(), rule_name.c_str());
StaticJsonBuffer<1024> jsonBuf;
JsonObject &root = jsonBuf.parseObject(event);
if (!root.success()) { return false; } // No valid JSON data
JsonObject *obj;
if (rule_task.startsWith("ROOT")) { // Support root level
if ((rule_task.length() == 0) || rule_task.startsWith("ROOT")) { // Support root level
obj = &root;
} else {
if (!root[rule_task].success()) { return false; } // No rule_task in JSON data