From d2915e9ad9e7bc181d0f69cda8cc5979ff028e3c Mon Sep 17 00:00:00 2001 From: Andrey Klimov Date: Tue, 15 Oct 2019 02:52:34 +0300 Subject: [PATCH] no @set command stored internally anymore to have clear differenciate on-off and value changing --- lighthub/item.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lighthub/item.cpp b/lighthub/item.cpp index 60d4d3e..e249ae3 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -72,8 +72,8 @@ const char POWER_P[] PROGMEM = "power"; const char VOL_P[] PROGMEM = "vol"; const char HEAT_P[] PROGMEM = "heat"; */ -const char HSV_P[] PROGMEM = "hsv"; -const char RGB_P[] PROGMEM = "rgb"; +const char HSV_P[] PROGMEM = "HSV"; +const char RGB_P[] PROGMEM = "RGB"; /* const char RPM_P[] PROGMEM = "rpm"; const char STATE_P[] PROGMEM = "state"; @@ -557,7 +557,7 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode case CMD_SET: // new style SET - w/o turning ON //if (/*itemType !=CH_THERMO && */send) setCmd(CMD_SET); //prevent ON thermostat by semp set ???? - setCmd(CMD_SET); ///??? trying + //////// setCmd(CMD_SET); ///??? trying... no switch (itemType) { case CH_RGBW: //only if configured VAL array @@ -593,8 +593,8 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode setVal(st.aslong); if (toExecute) { // - if (chActive && !st.v) setCmd(CMD_OFF); - if (!chActive && st.v) setCmd(CMD_ON); + if (chActive>0 && !st.v) setCmd(CMD_OFF); + if (chActive==0 && st.v) setCmd(CMD_ON); SendStatus(SEND_COMMAND | SEND_PARAMETERS | SEND_DEFFERED); } else SendStatus(SEND_PARAMETERS | SEND_DEFFERED); @@ -607,8 +607,8 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode // setCmd(cmd2changeActivity(chActive,cmd)); if (toExecute) { // Not restoring, working - if (chActive && !Par[0]) setCmd(CMD_OFF); - if (!chActive && Par[0]) setCmd(CMD_ON); + if (chActive>0 && !Par[0]) setCmd(CMD_OFF); + if (chActive==0 && Par[0]) setCmd(CMD_ON); SendStatus(SEND_COMMAND | SEND_PARAMETERS | SEND_DEFFERED); // Send back parameter for channel above this line } else SendStatus(SEND_PARAMETERS | SEND_DEFFERED); @@ -684,7 +684,7 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode switch (itemType) { case CH_GROUP: - if (send && !isActive()) SendStatus(SEND_COMMAND); // Just send ON, suppress send back ON of chan already active + if (send && isActive()==0) SendStatus(SEND_COMMAND); // Just send ON, suppress send back ON of chan already active break; case CH_RGBW: case CH_RGB: @@ -954,10 +954,13 @@ int Item::isActive() { CHstore st; int val = 0; - if (!isValid()) return -1; + debugSerial<name; - - + if (!isValid()) + { + debugSerial<valuestring); - if (it.isValid() && it.isActive()) { + if (it.isValid() && it.isActive()>0) { debugSerial<0) Ctrl(CMD_OFF); //Shut down /// modbusBusy=1; } else aJson.addNumberToObject(out, "flt", 0);