diff --git a/lib/jsmn-shadinger-1.0/src/JsonParser.cpp b/lib/jsmn-shadinger-1.0/src/JsonParser.cpp index f2ae50a97..6ebf6c2da 100644 --- a/lib/jsmn-shadinger-1.0/src/JsonParser.cpp +++ b/lib/jsmn-shadinger-1.0/src/JsonParser.cpp @@ -360,6 +360,9 @@ uint32_t JsonParserObject::getUInt(const char * needle, uint32_t val) const { uint64_t JsonParserObject::getULong(const char * needle, uint64_t val) const { return (*this)[needle].getULong(val); } +float JsonParserObject::getFloat(const char * needle, float val) const { + return (*this)[needle].getFloat(val); +} const char * JsonParserObject::getStr(const char * needle, const char * val) const { return (*this)[needle].getStr(val); } diff --git a/tasmota/xdrv_05_irremote.ino b/tasmota/xdrv_05_irremote.ino index 77a89a697..ebd1f06df 100644 --- a/tasmota/xdrv_05_irremote.ino +++ b/tasmota/xdrv_05_irremote.ino @@ -204,15 +204,15 @@ uint32_t IrRemoteCmndIrSendJson(void) uint16_t repeat = root[UpperCase_P(parm_uc, PSTR(D_JSON_IR_REPEAT))]; #else RemoveSpace(XdrvMailbox.data); // TODO is this really needed? - JsonParserObject root = JsonParser((chat*) XdrvMailbox.data).getRootObject(); + JsonParserObject root = JsonParser((char*) XdrvMailbox.data).getRootObject(); if (!root) { return IE_INVALID_JSON; } // IRsend { "protocol": "SAMSUNG", "bits": 32, "data": 551502015 } // IRsend { "protocol": "NEC", "bits": 32, "data":"0x02FDFE80", "repeat": 2 } - const char *protocol = root.getStr(PSTR(D_JSON_IR_PROTOCOL)); - uint16_t bits = root.getUInt(PSTR(D_JSON_IR_BITS)); - uint64_t data = root.getULong(PSTR(D_JSON_IR_DATA)); - uint16_t repeat = root.getUInt(PSTR(D_JSON_IR_REPEAT)); + const char *protocol = root.getStr(PSTR(D_JSON_IR_PROTOCOL), ""); + uint16_t bits = root.getUInt(PSTR(D_JSON_IR_BITS), 0); + uint64_t data = root.getULong(PSTR(D_JSON_IR_DATA), 0); + uint16_t repeat = root.getUInt(PSTR(D_JSON_IR_REPEAT), 0); #endif // check if the IRSend is great than repeat if (XdrvMailbox.index > repeat + 1) { diff --git a/tasmota/xdrv_05_irremote_full.ino b/tasmota/xdrv_05_irremote_full.ino index 846bd1b5d..d72711fc8 100644 --- a/tasmota/xdrv_05_irremote_full.ino +++ b/tasmota/xdrv_05_irremote_full.ino @@ -311,8 +311,8 @@ uint32_t IrRemoteCmndIrHvacJson(void) state.clean = false; // Turn off any Cleaning options if we can. state.clock = -1; // Don't set any current time if we can avoid it. - if (root[PSTR(D_JSON_IRHVAC_VENDOR)]) { state.protocol = strToDecodeType(root.getStr(PSTR(D_JSON_IRHVAC_VENDOR))); } - if (root[PSTR(D_JSON_IRHVAC_PROTOCOL)]) { state.protocol = strToDecodeType(root.getStr(PSTR(D_JSON_IRHVAC_PROTOCOL))); } + if (root[PSTR(D_JSON_IRHVAC_VENDOR)]) { state.protocol = strToDecodeType(root.getStr(PSTR(D_JSON_IRHVAC_VENDOR), "")); } + if (root[PSTR(D_JSON_IRHVAC_PROTOCOL)]) { state.protocol = strToDecodeType(root.getStr(PSTR(D_JSON_IRHVAC_PROTOCOL), "")); } // UpperCase_P(parm_uc, PSTR(D_JSON_IRHVAC_VENDOR)); // if (json.containsKey(parm_uc)) { state.protocol = strToDecodeType(json[parm_uc]); } // UpperCase_P(parm_uc, PSTR(D_JSON_IRHVAC_PROTOCOL)); @@ -331,10 +331,10 @@ uint32_t IrRemoteCmndIrHvacJson(void) } } - if (root[PSTR(D_JSON_IRHVAC_MODEL)]) { state.model = IRac::strToModel(PSTR(D_JSON_IRHVAC_MODEL)]); } - if (root[PSTR(D_JSON_IRHVAC_MODE)]) { state.mode = IRac::strToOpmode(PSTR(D_JSON_IRHVAC_MODE)]); } - if (root[PSTR(D_JSON_IRHVAC_SWINGV)]) { state.swingv = IRac::strToSwingV(PSTR(D_JSON_IRHVAC_SWINGV)]); } - if (root[PSTR(D_JSON_IRHVAC_SWINGH)]) { state.swingh = IRac::strToSwingV(PSTR(D_JSON_IRHVAC_SWINGH)]); } + if (root[PSTR(D_JSON_IRHVAC_MODEL)]) { state.model = IRac::strToModel(PSTR(D_JSON_IRHVAC_MODEL)); } + if (root[PSTR(D_JSON_IRHVAC_MODE)]) { state.mode = IRac::strToOpmode(PSTR(D_JSON_IRHVAC_MODE)); } + if (root[PSTR(D_JSON_IRHVAC_SWINGV)]) { state.swingv = IRac::strToSwingV(PSTR(D_JSON_IRHVAC_SWINGV)); } + if (root[PSTR(D_JSON_IRHVAC_SWINGH)]) { state.swingh = IRac::strToSwingH(PSTR(D_JSON_IRHVAC_SWINGH)); } state.degrees = root.getFloat(PSTR(D_JSON_IRHVAC_TEMP), state.degrees); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("model %d, mode %d, fanspeed %d, swingv %d, swingh %d"), // state.model, state.mode, state.fanspeed, state.swingv, state.swingh);