From 9ae6d9991ecd9a7ea5069fc62c17cc497e27b36d Mon Sep 17 00:00:00 2001 From: Andrey Klimov Date: Sat, 8 May 2021 11:36:18 +0300 Subject: [PATCH] Minimum ON volume for modbus dim, mask type=3 fix --- lighthub/item.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lighthub/item.cpp b/lighthub/item.cpp index a3c14ac..f5fb017 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -978,7 +978,18 @@ switch (itemType) { #ifndef MODBUS_DISABLE case CH_MODBUS: - if (toExecute) modbusDimmerSet(st); + if (toExecute) + { + int vol; + if (st.getCmd()== CMD_ON && (vol=st.getPercents())=0) + { + st.setPercents(INIT_VOLUME); + st.saveItem(this); + SendStatus(SEND_PARAMETERS | SEND_DEFFERED); + }; + + modbusDimmerSet(st); + } break; case CH_VC: if (toExecute) VacomSetFan(st); @@ -1521,8 +1532,10 @@ int Item::modbusDimmerSet(int addr, uint16_t _reg, int _regType, int _mask, uint break; case 2: break; - case 3: - value++; + case 3: // Modbus relay + //value++; + if (value) value = 1; + else value = 2; case 4: //Swap high and low bytes t = (value & 0xff00) >> 8; value <<=8;