You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[tuyamcu_v2] Fix suppressed dimmer updates from MQTT
The driver tried to avoid loops when state updates from the MCU (eg
from physical button press) could be reflected back by Tasmota and
trigger another MCU command, followed by a state update. It did this
by tracking the source of the command in the last_source and
last_command_source variables, suppressing the command if either of
those was SRC_SWITCH.
However this logic is faulty: Since there are two last_source
variables to check, a command might reset one of them, but the other
would still suppress one of them. As it turns out, MQTT commands would
only set last_source but not last_command_source. As a result, any
dimmer changes via MQTT would be dropped by the driver and not applied
to the MCU.
Switch functionality (on/off) was still working because those do not
rely on last_command_source, only last_source.
This change removes the loop detection logic altogether for dimmer
updates. This should be safe, because the driver already has the
latest dimmer value in its shadow state, and will not try to re-apply
a current value, thus breaking the loop.
This patch has been tested with several CE-WF500D dimmers which had
this problem.
if (value != bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1)) {
1621
1617
if (!value) { PowerOff = true; }
1622
-
ExecuteCommandPower(fnId - TUYA_MCU_FUNC_REL1 + 1, value, SRC_SWITCH);// send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
if (value != bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1_INV) ^ 1) {
1627
-
ExecuteCommandPower(fnId - TUYA_MCU_FUNC_REL1_INV + 1, value ^ 1, SRC_SWITCH);// send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
1623
+
ExecuteCommandPower(fnId - TUYA_MCU_FUNC_REL1_INV + 1, value ^ 1, SRC_SWITCH);
0 commit comments