From fb7bafdb87f235c9c1f202365f50ce7e92b5fcdc Mon Sep 17 00:00:00 2001 From: proddy Date: Wed, 20 Oct 2021 09:34:50 +0200 Subject: [PATCH] fix display of mqtt subscriptions --- src/mqtt.cpp | 6 ++++-- src/test/test.cpp | 3 ++- src/test/test.h | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 841bbcc1f..e131fd8b9 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -225,8 +225,10 @@ void Mqtt::show_mqtt(uuid::console::Shell & shell) { for (const auto & mqtt_subfunction : mqtt_subfunctions_) { shell.printfln(F(" %s/%s"), mqtt_base_.c_str(), mqtt_subfunction.topic_.c_str()); } + + // now show the commands... for (const auto & cf : Command::commands()) { - if (subscribe_format_ == 2 && cf.has_flags(CommandFlag::MQTT_SUB_FLAG_HC)) { + if (subscribe_format_ == Subscribe_Format::INDIVIDUAL_ALL_HC && cf.has_flags(CommandFlag::MQTT_SUB_FLAG_HC)) { shell.printfln(F(" %s/%s/hc1/%s"), mqtt_base_.c_str(), EMSdevice::device_type_2_device_name(cf.device_type_).c_str(), @@ -243,7 +245,7 @@ void Mqtt::show_mqtt(uuid::console::Shell & shell) { mqtt_base_.c_str(), EMSdevice::device_type_2_device_name(cf.device_type_).c_str(), uuid::read_flash_string(cf.cmd_).c_str()); - } else if (subscribe_format_ == 1 && !cf.has_flags(CommandFlag::MQTT_SUB_FLAG_NOSUB)) { + } else if (subscribe_format_ != Subscribe_Format::GENERAL && !cf.has_flags(CommandFlag::MQTT_SUB_FLAG_NOSUB)) { shell.printfln(F(" %s/%s/%s"), mqtt_base_.c_str(), EMSdevice::device_type_2_device_name(cf.device_type_).c_str(), diff --git a/src/test/test.cpp b/src/test/test.cpp index 89d5ccdfc..2ef6e7c9d 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -474,7 +474,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) { if (command == "mqtt_individual") { shell.printfln(F("Testing individual MQTT")); Mqtt::ha_enabled(false); // turn off HA Discovery to stop the chatter - Mqtt::subscribe_format(1); // individual topics + Mqtt::subscribe_format(2); // individual topics, all HC + // Mqtt::subscribe_format(1); // individual topics, only main HC run_test("boiler"); run_test("thermostat"); diff --git a/src/test/test.h b/src/test/test.h index 6e3422e53..c776c21b2 100644 --- a/src/test/test.h +++ b/src/test/test.h @@ -39,9 +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 "mqtt_individual" +#define EMSESP_DEBUG_DEFAULT "mqtt_individual" class Test { public: