From 3d4ed40804939b3f8edb064ea1eca698c37a1296 Mon Sep 17 00:00:00 2001 From: Shantur Rathore Date: Thu, 24 Oct 2019 16:06:03 +0100 Subject: [PATCH] TuyaMcu: Fix Relays aren't using correct DpIds. --- sonoff/xdrv_16_tuyamcu.ino | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sonoff/xdrv_16_tuyamcu.ino b/sonoff/xdrv_16_tuyamcu.ino index 797cdba8f..2cf63c8d0 100644 --- a/sonoff/xdrv_16_tuyamcu.ino +++ b/sonoff/xdrv_16_tuyamcu.ino @@ -276,8 +276,11 @@ bool TuyaSetPower(void) uint8_t rpower = XdrvMailbox.index; int16_t source = XdrvMailbox.payload; + uint8_t dpid = TuyaGetDpId(TUYA_MCU_FUNC_REL1 + active_device - 1); + if (dpid == 0) dpid = TuyaGetDpId(TUYA_MCU_FUNC_REL1_INV + active_device - 1); + if (source != SRC_SWITCH && TuyaSerial) { // ignore to prevent loop from pushing state from faceplate interaction - TuyaSendBool(active_device, bitRead(rpower, active_device-1) ^ bitRead(rel_inverted, active_device-1)); + TuyaSendBool(dpid, bitRead(rpower, active_device-1) ^ bitRead(rel_inverted, active_device-1)); status = true; } return status;