Add rule System#Save executed just before a planned restart

Add rule System#Save executed just before a planned restart
This commit is contained in:
Theo Arends 2019-05-19 12:42:10 +02:00
parent ef9f0f6453
commit 8c132bd0ff
2 changed files with 14 additions and 0 deletions

View File

@ -1,6 +1,7 @@
/* 6.5.0.11 20190517
* Add command SetOption64 0/1 to switch between "-" or "_" as sensor index separator impacting DS18X20, DHT, BMP and SHT3X sensor names (#5689)
* Add initial support for Scripts as replacement for Rules. Default disabled but can be enabled in my_user_config.h (#5689)
* Add rule System#Save executed just before a planned restart
*
* 6.5.0.10 20190513
* Enable ADC0 by default in my_user_config.h (#5671)

View File

@ -587,6 +587,16 @@ void RulesEverySecond(void)
}
}
void RulesSaveBeforeRestart(void)
{
if (Settings.rule_enabled) { // Any rule enabled
char json_event[32];
strncpy_P(json_event, PSTR("{\"System\":{\"Save\":1}}"), sizeof(json_event));
RulesProcessEvent(json_event);
}
}
void RulesSetPower(void)
{
rules_new_power = XdrvMailbox.index;
@ -1279,6 +1289,9 @@ bool Xdrv10(uint8_t function)
case FUNC_RULES_PROCESS:
result = RulesProcess();
break;
case FUNC_SAVE_BEFORE_RESTART:
RulesSaveBeforeRestart();
break;
#ifdef SUPPORT_MQTT_EVENT
case FUNC_MQTT_DATA:
result = RulesMqttData();