diff --git a/lighthub/itemCmd.cpp b/lighthub/itemCmd.cpp index eb4646f..acea3c8 100644 --- a/lighthub/itemCmd.cpp +++ b/lighthub/itemCmd.cpp @@ -1181,6 +1181,7 @@ return false; i=i->next; } } + break; case aJson_String: if (strcmp(cmdMapping->valuestring,"fan")==0) switch (getCmd()) @@ -1209,7 +1210,10 @@ return false; } //switch -if (matchedCmd) return itemCmd().Int((uint32_t)matchedCmd->valueint); +if (matchedCmd && matchedCmd->type != aJson_NULL) + { + return itemCmd().Int((uint32_t)matchedCmd->valueint); + } aJsonObject *valMapping = aJson.getObjectItem(mappingData, "val"); if (isValue() && valMapping && valMapping->type == aJson_Array && aJson.getArraySize(valMapping) == 4) @@ -1220,7 +1224,7 @@ if (isValue() && valMapping && valMapping->type == aJson_Array && aJson.getArray aJson.getArrayItem(valMapping,0)->valueint,aJson.getArrayItem(valMapping,1)->valueint, aJson.getArrayItem(valMapping,2)->valueint,aJson.getArrayItem(valMapping,3)->valueint)); } - else if (valMapping && valMapping->type == aJson_NULL) cmd.itemArgType = ST_VOID; + else if (valMapping && valMapping->type == aJson_NULL) return itemCmd(ST_VOID,CMD_VOID); return *this; } diff --git a/lighthub/modules/out_modbus.cpp b/lighthub/modules/out_modbus.cpp index ed74b53..93fe93f 100644 --- a/lighthub/modules/out_modbus.cpp +++ b/lighthub/modules/out_modbus.cpp @@ -567,7 +567,8 @@ if (!suffixCode) return 0; char *suffixStr =templateParamObj->name; // We have find template for suffix or suffixCode -long Value = 0; +itemCmd cmdValue = itemCmd(ST_VOID,CMD_VOID); +long Value = 0; int8_t regType = PAR_I16; aJsonObject * typeObj = aJson.getObjectItem(templateParamObj, "type"); aJsonObject * mapObj = aJson.getObjectItem(templateParamObj, "map"); @@ -583,13 +584,19 @@ aJsonObject * mapObj = aJson.getObjectItem(templateParamObj, "map"); case PAR_I8H: case PAR_I8L: - Value=cmd.doMapping(mapObj).getInt(); + cmdValue=cmd.doMapping(mapObj); + if (!cmdValue.isValue())return 0; + Value=cmdValue.getInt(); break; case PAR_TENS: - Value=cmd.doMapping(mapObj).getTens(); + cmdValue=cmd.doMapping(mapObj); + if (!cmdValue.isValue())return 0; + Value=cmdValue.getTens(); break; case PAR_100: - Value=cmd.doMapping(mapObj).getTens_raw()*(100/TENS_BASE); + cmdValue=cmd.doMapping(mapObj); + if (!cmdValue.isValue())return 0; + Value=cmdValue.getTens_raw()*(100/TENS_BASE); } debugSerial<