diff --git a/lighthub/item.cpp b/lighthub/item.cpp index efde561..a3ac831 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -49,6 +49,8 @@ extern int8_t ethernetIdleCount; static unsigned long lastctrl = 0; static aJsonObject *lastobj = NULL; +int retrieveCode(char **psubItem); + int txt2cmd(char *payload) { int cmd = CMD_UNKNOWN; @@ -165,9 +167,29 @@ Item::~Item() Item::Item(char *name) //Constructor { + char * pDefaultSubItem = defaultSubItem; driver = NULL; + defaultSubItem[0] =0; + defaultSuffixCode = 0; if (name && items) + { char* sub; + if (sub=strchr(name,'/')) + { + char buf [MQTT_SUBJECT_LENGTH]; + short i; + for(i=0;(name[i] && (name[i]!='/') && (iCtrl(cmd, n, Parameters, send, suffixCode, subItem); break; - +*/ default: res = driver->Ctrl(cmd, n, Parameters, send, suffixCode, subItem); setCmd(cmd); @@ -517,11 +567,12 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode } // Legacy monolite core code bool toExecute = (chActive>0); //if channel is already active - unconditionally propogate changes - switch (cmd) { - case 0: // old style SET - with turning ON - toExecute = true; - case CMD_SET: // new style SET - w/o turning ON + switch (cmd) { + case 0: // No command - set params + // toExecute = true; + // case CMD_SET: // new style SET - w/o turning ON + if (!suffixCode) toExecute= true; //if (/*itemType !=CH_THERMO && */send) setCmd(CMD_SET); //prevent ON thermostat by semp set ???? //////// setCmd(CMD_SET); ///??? trying... no switch (itemType) { @@ -1522,7 +1573,7 @@ int Item::SendStatus(int sendFlags) { strcpy_P(cmdstr, OFF_P); break; case 0: - case CMD_SET: + /// case CMD_SET: sendFlags &= ~SEND_COMMAND; // Not send command for parametrized req break; default: diff --git a/lighthub/item.h b/lighthub/item.h index 9769af1..f0e5da0 100644 --- a/lighthub/item.h +++ b/lighthub/item.h @@ -73,7 +73,7 @@ e-mail anklimov@gmail.com #define CMD_AUTO 0xc #define CMD_FAN 0xd #define CMD_DRY 0xe -#define CMD_SET 0xf +//#define CMD_SET 0xf #define CMD_HIGH 0x10 //AC fan leve #define CMD_MED 0x11 #define CMD_LOW 0x12 @@ -179,7 +179,7 @@ class Item int SendStatus(int sendFlags); int isActive(); protected: - short cmd2changeActivity(int lastActivity, short defaultCmd = CMD_SET); + //short cmd2changeActivity(int lastActivity, short defaultCmd = CMD_SET); int VacomSetFan (int8_t val, int8_t cmd=0); int VacomSetHeat(int addr, int8_t val, int8_t cmd=0); int modbusDimmerSet(int addr, uint16_t _reg, int _regType, int _mask, uint16_t value); @@ -192,5 +192,7 @@ class Item void sendDelayedStatus(); int checkFM(); + char defaultSubItem[10]; + int defaultSuffixCode; };