mirror of https://github.com/arendst/Tasmota.git
Bugfix: power0 if power_lock is used (#21102)
* Bug Fix: power_lock with Power0 command Power0 changed power regardless of the new lock state of power. New implementation respect the LOCK also on global change * simplify * readded the all_on filter to power_lock change readded the all_on to ensure new defined relays always start with power off ass intended.
This commit is contained in:
parent
cbd533c1e9
commit
b9a0ae98df
|
@ -392,13 +392,17 @@ void SetAllPower(uint32_t state, uint32_t source)
|
|||
power_t all_on = POWER_MASK >> (POWER_SIZE - TasmotaGlobal.devices_present);
|
||||
switch (state) {
|
||||
case POWER_OFF:
|
||||
TasmotaGlobal.power = 0;
|
||||
break;
|
||||
// keep loocked bits and set all other to 0
|
||||
TasmotaGlobal.power &= Settings->power_lock;
|
||||
break;
|
||||
case POWER_ON:
|
||||
TasmotaGlobal.power = all_on;
|
||||
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:
|
||||
TasmotaGlobal.power ^= all_on; // Complement current state
|
||||
// Keep locked bits and toggle all other
|
||||
TasmotaGlobal.power ^= ~Settings->power_lock & all_on;
|
||||
break;
|
||||
}
|
||||
SetDevicePower(TasmotaGlobal.power, source);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue