diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index 5b35d0911..4e15114bc 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -812,8 +812,8 @@ void Boiler::process_UBAErrorMessage(std::shared_ptr telegram) { } } } -// 0xC2 +// 0xC2 void Boiler::process_UBAErrorMessage2(std::shared_ptr telegram) { if (telegram->offset > 0 || telegram->message_length < 14) { return; diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 7ac599ec5..2018d4264 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -260,11 +260,11 @@ void Mqtt::on_message(const char * topic, const char * payload, size_t len) { StaticJsonDocument output_doc; JsonObject input, output; - // convert payload into a json doc, if it's not empty - // if the payload is a single parameter (not JSON) create a JSON with the key 'value' + // convert payload into a json doc + // if the payload doesn't not contain the key 'value' or 'data', treat the whole payload as the 'value' if (len != 0) { DeserializationError error = deserializeJson(input_doc, message); - if (!input_doc.containsKey("value") || error) { + if ((!input_doc.containsKey("value") && !input_doc.containsKey("data")) || error) { input_doc.clear(); input_doc["value"] = (const char *)message; // always a string } diff --git a/src/test/test.cpp b/src/test/test.cpp index 9ee938159..d0a6fe8d8 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -671,6 +671,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) { EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp", "59"); EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp"); + EMSESP::mqtt_.incoming("ems-esp/thermostat", "{\"cmd\":\"mode\",\"data\":\"heat\",\"id\":1}"); + // MQTT bad tests EMSESP::mqtt_.incoming("ems-esp/thermostate/mode", "auto"); // unknown device EMSESP::mqtt_.incoming("ems-esp/thermostat/modee", "auto"); // unknown command @@ -757,7 +759,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) { request.url("/rest/writeValue"); EMSESP::webDataService.write_value(&request, json); - emsesp::EMSESP::logger().notice("*"); + // emsesp::EMSESP::logger().notice("*"); // should fail char data8[] = "{}"; diff --git a/src/test/test.h b/src/test/test.h index ba62d7215..1a7a9a7fc 100644 --- a/src/test/test.h +++ b/src/test/test.h @@ -39,10 +39,9 @@ namespace emsesp { // #define EMSESP_DEBUG_DEFAULT "shower_alert" // #define EMSESP_DEBUG_DEFAULT "310" // #define EMSESP_DEBUG_DEFAULT "render" -// #define EMSESP_DEBUG_DEFAULT "api" +#define EMSESP_DEBUG_DEFAULT "api" // #define EMSESP_DEBUG_DEFAULT "crash" -#define EMSESP_DEBUG_DEFAULT "dv" - +// #define EMSESP_DEBUG_DEFAULT "dv" class Test { public: