diff --git a/tasmota/include/tasmota.h b/tasmota/include/tasmota.h index 650eddf56..ca1653037 100644 --- a/tasmota/include/tasmota.h +++ b/tasmota/include/tasmota.h @@ -371,7 +371,7 @@ enum TopicOptions { CMND, STAT, TELE, nu1, RESULT_OR_CMND, RESULT_OR_STAT, RESUL enum UploadTypes { UPL_TASMOTA = 1, UPL_SETTINGS, UPL_EFM8BB1, UPL_TASMOTACLIENT, UPL_EFR32, UPL_SHD, UPL_CCL, UPL_UFSFILE }; -enum ExecuteCommandPowerOptions { POWER_OFF, POWER_ON, POWER_TOGGLE, POWER_BLINK, POWER_BLINK_STOP, +enum ExecuteCommandPowerOptions { POWER_OFF, POWER_ON, POWER_TOGGLE, POWER_BLINK, POWER_BLINK_STOP, POWER_OFF_FORCE, POWER_OFF_NO_STATE = 8, POWER_ON_NO_STATE, POWER_TOGGLE_NO_STATE, POWER_SHOW_STATE = 16 }; enum SendKeyPowerOptions { POWER_HOLD = 3, POWER_INCREMENT = 4, POWER_INV = 5, POWER_CLEAR = 6, POWER_RELEASE = 7, diff --git a/tasmota/tasmota_support/support_tasmota.ino b/tasmota/tasmota_support/support_tasmota.ino index a8b0ba755..0af57d62f 100644 --- a/tasmota/tasmota_support/support_tasmota.ino +++ b/tasmota/tasmota_support/support_tasmota.ino @@ -373,11 +373,11 @@ void RestorePower(bool publish_power, uint32_t source) } } -void SetAllPower(uint32_t state, uint32_t source) -{ +void SetAllPower(uint32_t state, uint32_t source) { // state 0 = POWER_OFF = Relay Off // state 1 = POWER_ON = Relay On (turn off after Settings->pulse_timer * 100 mSec if enabled) // state 2 = POWER_TOGGLE = Toggle relay +// state 5 = POWER_OFF_FORCE = Relay Off even if locked // state 8 = POWER_OFF_NO_STATE = Relay Off and no publishPowerState // state 9 = POWER_ON_NO_STATE = Relay On and no publishPowerState // state 10 = POWER_TOGGLE_NO_STATE = Toggle relay and no publishPowerState @@ -388,21 +388,25 @@ void SetAllPower(uint32_t state, uint32_t source) state &= 3; // POWER_OFF, POWER_ON or POWER_TOGGLE publish_power = false; } - if ((state >= POWER_OFF) && (state <= POWER_TOGGLE)) { + if (((state >= POWER_OFF) && (state <= POWER_TOGGLE)) || (POWER_OFF_FORCE == state)) { power_t all_on = POWER_MASK >> (POWER_SIZE - TasmotaGlobal.devices_present); switch (state) { case POWER_OFF: - // keep loocked bits and set all other to 0 - TasmotaGlobal.power &= Settings->power_lock; - break; + // Keep locked bits and set all other to 0 + TasmotaGlobal.power &= Settings->power_lock; + break; case POWER_ON: - // Keep locked bits and set all other to 1 - TasmotaGlobal.power = (TasmotaGlobal.power & Settings->power_lock) | (all_on & ~Settings->power_lock); - break; + // Keep locked bits and set all other to 1 + TasmotaGlobal.power = (TasmotaGlobal.power & Settings->power_lock) | (all_on & ~Settings->power_lock); + break; case POWER_TOGGLE: - // Keep locked bits and toggle all other - TasmotaGlobal.power ^= ~Settings->power_lock & all_on; - break; + // Keep locked bits and toggle all other + TasmotaGlobal.power ^= ~Settings->power_lock & all_on; + break; + case POWER_OFF_FORCE: + // Set all off even if locked on (Used by overtemp and overcurrent) + TasmotaGlobal.power = 0; + break; } SetDevicePower(TasmotaGlobal.power, source); } diff --git a/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino b/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino index b2ca4aada..8449d22c7 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino @@ -581,7 +581,7 @@ void EnergyMarginCheck(void) { ResponseTime_P(PSTR(",\"" D_JSON_MAXPOWERREACHED "\":%d}"), energy_power_u); MqttPublishPrefixTopicRulesProcess_P(STAT, S_RSLT_WARNING); EnergyMqttShow(); - SetAllPower(POWER_ALL_OFF, SRC_MAXPOWER); + SetAllPower(POWER_OFF_FORCE, SRC_MAXPOWER); if (!Energy->mplr_counter) { Energy->mplr_counter = Settings->param[P_MAX_POWER_RETRY] +1; // SetOption33 - Max Power Retry count } @@ -608,7 +608,7 @@ void EnergyMarginCheck(void) { ResponseTime_P(PSTR(",\"" D_JSON_MAXPOWERREACHEDRETRY "\":\"%s\"}"), GetStateText(0)); MqttPublishPrefixTopicRulesProcess_P(STAT, S_RSLT_WARNING); EnergyMqttShow(); - SetAllPower(POWER_ALL_OFF, SRC_MAXPOWER); + SetAllPower(POWER_OFF_FORCE, SRC_MAXPOWER); } } } @@ -629,7 +629,7 @@ void EnergyMarginCheck(void) { ResponseTime_P(PSTR(",\"" D_JSON_MAXENERGYREACHED "\":%3_f}"), &Energy->daily_sum); MqttPublishPrefixTopicRulesProcess_P(STAT, S_RSLT_WARNING); EnergyMqttShow(); - SetAllPower(POWER_ALL_OFF, SRC_MAXENERGY); + SetAllPower(POWER_OFF_FORCE, SRC_MAXENERGY); } } #endif // USE_ENERGY_POWER_LIMIT @@ -656,7 +656,7 @@ void EnergyEverySecond(void) { AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Temperature %1_f"), &TasmotaGlobal.temperature_celsius); - SetAllPower(POWER_ALL_OFF, SRC_OVERTEMP); + SetAllPower(POWER_OFF_FORCE, SRC_OVERTEMP); } } diff --git a/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino b/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino index bc7b9428b..05e17d5f1 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino @@ -803,7 +803,7 @@ void EnergyMarginCheck(void) { ResponseTime_P(PSTR(",\"" D_JSON_MAXPOWERREACHED "\":%d}"), energy_power_u); MqttPublishPrefixTopicRulesProcess_P(STAT, S_RSLT_WARNING); EnergyMqttShow(); - SetAllPower(POWER_ALL_OFF, SRC_MAXPOWER); + SetAllPower(POWER_OFF_FORCE, SRC_MAXPOWER); if (!Energy->mplr_counter) { Energy->mplr_counter = Settings->param[P_MAX_POWER_RETRY] +1; // SetOption33 - Max Power Retry count } @@ -830,7 +830,7 @@ void EnergyMarginCheck(void) { ResponseTime_P(PSTR(",\"" D_JSON_MAXPOWERREACHEDRETRY "\":\"%s\"}"), GetStateText(0)); MqttPublishPrefixTopicRulesProcess_P(STAT, S_RSLT_WARNING); EnergyMqttShow(); - SetAllPower(POWER_ALL_OFF, SRC_MAXPOWER); + SetAllPower(POWER_OFF_FORCE, SRC_MAXPOWER); } } } @@ -851,7 +851,7 @@ void EnergyMarginCheck(void) { ResponseTime_P(PSTR(",\"" D_JSON_MAXENERGYREACHED "\":%3_f}"), &Energy->daily_sum); MqttPublishPrefixTopicRulesProcess_P(STAT, S_RSLT_WARNING); EnergyMqttShow(); - SetAllPower(POWER_ALL_OFF, SRC_MAXENERGY); + SetAllPower(POWER_OFF_FORCE, SRC_MAXENERGY); } } EnergyFmtFree(); @@ -876,7 +876,7 @@ void EnergyEverySecond(void) { AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Temperature %1_f"), &TasmotaGlobal.temperature_celsius); - SetAllPower(POWER_ALL_OFF, SRC_OVERTEMP); + SetAllPower(POWER_OFF_FORCE, SRC_OVERTEMP); } }