diff --git a/tasmota/xdrv_23_zigbee_9_impl.ino b/tasmota/xdrv_23_zigbee_9_impl.ino index cb08eeaee..9a08c3585 100644 --- a/tasmota/xdrv_23_zigbee_9_impl.ino +++ b/tasmota/xdrv_23_zigbee_9_impl.ino @@ -235,13 +235,14 @@ void ZigbeeInit(void) * Commands \*********************************************************************************************/ -uint32_t strToUInt(const JsonVariant val) { +uint32_t strToUInt(const JsonVariant &val) { // if the string starts with 0x, it is considered Hex, otherwise it is an int if (val.is()) { return val.as(); } else { - if (val.is()) { - return strtoull(val.as(), nullptr, 0); + if (val.is()) { + String sval = val.as(); + return strtoull(sval.c_str(), nullptr, 0); } } return 0; // couldn't parse anything @@ -593,6 +594,7 @@ void CmndZigbeeRead(void) { const JsonVariant &val_attr = getCaseInsensitive(json, PSTR("Read")); if (nullptr != &val_attr) { + uint16_t val = strToUInt(val_attr); if (val_attr.is()) { JsonArray& attr_arr = val_attr; attrs_len = attr_arr.size() * 2; @@ -604,11 +606,9 @@ void CmndZigbeeRead(void) { attrs[i++] = val & 0xFF; attrs[i++] = val >> 8; } - } else { attrs_len = 2; attrs = new uint8_t[attrs_len]; - uint16_t val = strToUInt(val_attr); attrs[0] = val & 0xFF; // little endian attrs[1] = val >> 8; }