From 86af0df7123bab646a08e75b2d92d7db2420f785 Mon Sep 17 00:00:00 2001 From: thirug010 <30732819+thirug010@users.noreply.github.com> Date: Mon, 20 May 2019 16:37:23 -0500 Subject: [PATCH] update the Code to prevent the multiple power mqtt update the xdrv_16_tuyadimmer.ino to prevent the multiple mqtt msg for power status. --- sonoff/xdrv_16_tuyadimmer.ino | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino index 202674ac5..6e16efc51 100644 --- a/sonoff/xdrv_16_tuyadimmer.ino +++ b/sonoff/xdrv_16_tuyadimmer.ino @@ -195,11 +195,14 @@ void TuyaPacketProcess(void) case TUYA_CMD_STATE: if (tuya_buffer[5] == 5) { // on/off packet - AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX Device -%d --> %s State"),tuya_buffer[6],tuya_buffer[10]?"On":"Off"); - ExecuteCommandPower(tuya_buffer[6], tuya_buffer[10], SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction /*if((power || Settings.light_dimmer > 0) && (power != tuya_buffer[10])) { ExecuteCommandPower(1, tuya_buffer[10], SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction }*/ + AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX Device-%d --> MCU State: %s Current State:%s"),tuya_buffer[6],tuya_buffer[10]?"On":"Off",bitRead(power, tuya_buffer[6]-1)?"On":"Off"); + if((power || Settings.light_dimmer > 0) && (tuya_buffer[10] != bitRead(power, tuya_buffer[6]-1))) + { + ExecuteCommandPower(tuya_buffer[6], tuya_buffer[10], SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction + } } else if (tuya_buffer[5] == 8) { // dim packet