Merge pull request #208 from proddy:dev

fixes #207
This commit is contained in:
Proddy
2021-11-19 13:00:58 +01:00
committed by GitHub
4 changed files with 9 additions and 8 deletions

View File

@@ -812,8 +812,8 @@ void Boiler::process_UBAErrorMessage(std::shared_ptr<const Telegram> telegram) {
} }
} }
} }
// 0xC2
// 0xC2
void Boiler::process_UBAErrorMessage2(std::shared_ptr<const Telegram> telegram) { void Boiler::process_UBAErrorMessage2(std::shared_ptr<const Telegram> telegram) {
if (telegram->offset > 0 || telegram->message_length < 14) { if (telegram->offset > 0 || telegram->message_length < 14) {
return; return;

View File

@@ -260,11 +260,11 @@ void Mqtt::on_message(const char * topic, const char * payload, size_t len) {
StaticJsonDocument<EMSESP_JSON_SIZE_LARGE_DYN> output_doc; StaticJsonDocument<EMSESP_JSON_SIZE_LARGE_DYN> output_doc;
JsonObject input, output; JsonObject input, output;
// convert payload into a json doc, if it's not empty // convert payload into a json doc
// if the payload is a single parameter (not JSON) create a JSON with the key 'value' // if the payload doesn't not contain the key 'value' or 'data', treat the whole payload as the 'value'
if (len != 0) { if (len != 0) {
DeserializationError error = deserializeJson(input_doc, message); 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.clear();
input_doc["value"] = (const char *)message; // always a string input_doc["value"] = (const char *)message; // always a string
} }

View File

@@ -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", "59");
EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp"); EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp");
EMSESP::mqtt_.incoming("ems-esp/thermostat", "{\"cmd\":\"mode\",\"data\":\"heat\",\"id\":1}");
// MQTT bad tests // MQTT bad tests
EMSESP::mqtt_.incoming("ems-esp/thermostate/mode", "auto"); // unknown device EMSESP::mqtt_.incoming("ems-esp/thermostate/mode", "auto"); // unknown device
EMSESP::mqtt_.incoming("ems-esp/thermostat/modee", "auto"); // unknown command 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"); request.url("/rest/writeValue");
EMSESP::webDataService.write_value(&request, json); EMSESP::webDataService.write_value(&request, json);
emsesp::EMSESP::logger().notice("*"); // emsesp::EMSESP::logger().notice("*");
// should fail // should fail
char data8[] = "{}"; char data8[] = "{}";

View File

@@ -39,10 +39,9 @@ namespace emsesp {
// #define EMSESP_DEBUG_DEFAULT "shower_alert" // #define EMSESP_DEBUG_DEFAULT "shower_alert"
// #define EMSESP_DEBUG_DEFAULT "310" // #define EMSESP_DEBUG_DEFAULT "310"
// #define EMSESP_DEBUG_DEFAULT "render" // #define EMSESP_DEBUG_DEFAULT "render"
// #define EMSESP_DEBUG_DEFAULT "api" #define EMSESP_DEBUG_DEFAULT "api"
// #define EMSESP_DEBUG_DEFAULT "crash" // #define EMSESP_DEBUG_DEFAULT "crash"
#define EMSESP_DEBUG_DEFAULT "dv" // #define EMSESP_DEBUG_DEFAULT "dv"
class Test { class Test {
public: public: