Skip to content

Commit

Permalink
remove useless extra subscriptions #173
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Nov 4, 2021
1 parent 452921d commit 8d9fd95
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/emsesp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,10 +1049,8 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, std::
[device_type](const char * value, const int8_t id, JsonObject & output) { return command_entities(device_type, output, id); },
F_(entities_cmd));

// MQTT subscribe to the device
Mqtt::subscribe(device_type, EMSdevice::device_type_2_device_name(device_type), nullptr); // e.g. "ems-esp/boiler"
std::string topic = EMSdevice::device_type_2_device_name(device_type) + "/#";
Mqtt::subscribe(device_type, topic, nullptr); // e.g. "ems-esp/boiler/#"
// MQTT subscribe to the device e.g. "ems-esp/boiler/#"
Mqtt::subscribe(device_type, EMSdevice::device_type_2_device_name(device_type) + "/#", nullptr);

// Print to LOG showing we've added a new device
LOG_INFO(F("Recognized new %s with device ID 0x%02X"), EMSdevice::device_type_2_device_name(device_type).c_str(), device_id);
Expand Down
3 changes: 1 addition & 2 deletions src/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,8 @@ void System::commands_init() {
Command::add(EMSdevice::DeviceType::SYSTEM, F("test"), System::command_test, F("run tests"));
#endif

// MQTT subscribe "ems-esp/system/#" and "ems-esp/system"
// MQTT subscribe "ems-esp/system/#"
Mqtt::subscribe(EMSdevice::DeviceType::SYSTEM, "system/#", nullptr); // use empty function callback
Mqtt::subscribe(EMSdevice::DeviceType::SYSTEM, "system", nullptr); // use empty function callback
}

// flashes the LED
Expand Down

0 comments on commit 8d9fd95

Please sign in to comment.