Add restore power state when limit is restored

Add restore power state when limit is restored (#6340)
This commit is contained in:
Theo Arends 2019-09-03 22:27:54 +02:00
parent 1478f1624a
commit 41f76c5128
2 changed files with 6 additions and 5 deletions

View File

@ -598,10 +598,11 @@ void SetAllPower(uint8_t state, int source)
}
}
void RestoreAllPower(power_t power_set, int source)
void RestorePower(power_t power_set, int source)
{
if (power != power_set) {
SetDevicePower(power, source);
power_t new_state = power | power_set;
if (power != new_state) {
SetDevicePower(new_state, source);
MqttPublishAllPowerState();
}
}

View File

@ -342,7 +342,7 @@ void EnergyMarginCheck(void)
if (Energy.mplr_counter) {
Response_P(PSTR("{\"" D_JSON_POWERMONITOR "\":\"%s\"}"), GetStateText(1));
MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_JSON_POWERMONITOR));
RestoreAllPower(Energy.mp_last_power, SRC_MAXPOWER);
RestorePower(Energy.mp_last_power, SRC_MAXPOWER);
} else {
Response_P(PSTR("{\"" D_JSON_MAXPOWERREACHEDRETRY "\":\"%s\"}"), GetStateText(0));
MqttPublishPrefixTopic_P(STAT, S_RSLT_WARNING);
@ -360,7 +360,7 @@ void EnergyMarginCheck(void)
Energy.max_energy_state = 1;
Response_P(PSTR("{\"" D_JSON_ENERGYMONITOR "\":\"%s\"}"), GetStateText(1));
MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_JSON_ENERGYMONITOR));
RestoreAllPower(Energy.me_last_power, SRC_MAXENERGY);
RestorePower(Energy.me_last_power, SRC_MAXENERGY);
}
else if ((1 == Energy.max_energy_state ) && (energy_daily_u >= Settings.energy_max_energy)) {
Energy.max_energy_state = 2;