diff --git a/src/console.cpp b/src/console.cpp index 74c2af440..9d2748d96 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -563,9 +563,9 @@ static void setup_commands(std::shared_ptr & commands) { } return devices_list; } else if (current_arguments.size() == 1) { - std::vector command_list; - uint8_t device_type = EMSdevice::device_name_2_device_type(current_arguments[0].c_str()); + uint8_t device_type = EMSdevice::device_name_2_device_type(current_arguments[0].c_str()); if (Command::device_has_commands(device_type)) { + std::vector command_list; for (const auto & cf : Command::commands()) { if (cf.device_type_ == device_type) { command_list.emplace_back(cf.cmd_); diff --git a/src/emsesp.cpp b/src/emsesp.cpp index f2bfc6a2c..5d79f1790 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -392,7 +392,6 @@ void EMSESP::show_device_values(uuid::console::Shell & shell) { // extract the shortname from the key, which is in brackets std::size_t first_bracket = key.find_last_of('('); std::size_t last_bracket = key.find_last_of(')'); - std::string shortname = key.substr(first_bracket + 1, last_bracket - first_bracket - 1); std::string uom = emsdevice->get_value_uom(key.substr(first_bracket + 1, last_bracket - first_bracket - 1)); shell.printfln(" %s: %s%s %s%s", key.c_str(), COLOR_BRIGHT_GREEN, p.value().as().c_str(), uom.c_str(), COLOR_RESET); diff --git a/src/system.cpp b/src/system.cpp index 31bcfaf4a..14caf9e5f 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -629,7 +629,7 @@ void System::send_info_mqtt() { } // create the json for heartbeat -bool System::heartbeat_json(JsonObject output) { +void System::heartbeat_json(JsonObject output) { uint8_t bus_status = EMSESP::bus_status(); if (bus_status == EMSESP::BUS_STATUS_TX_ERRORS) { output["bus_status"] = "txerror"; @@ -681,8 +681,6 @@ bool System::heartbeat_json(JsonObject output) { output["wifistrength"] = wifi_quality(rssi); } #endif - - return true; } // send periodic MQTT message with system information @@ -697,9 +695,8 @@ void System::send_heartbeat() { JsonDocument doc; JsonObject json = doc.to(); - if (heartbeat_json(json)) { - Mqtt::queue_publish(F_(heartbeat), json); // send to MQTT with retain off. This will add to MQTT queue. - } + heartbeat_json(json); + Mqtt::queue_publish(F_(heartbeat), json); // send to MQTT with retain off. This will add to MQTT queue. } // initializes network diff --git a/src/system.h b/src/system.h index acfc11b89..ccff2ae71 100644 --- a/src/system.h +++ b/src/system.h @@ -79,7 +79,7 @@ class System { void syslog_init(); bool check_upgrade(bool factory_settings); bool check_restore(); - bool heartbeat_json(JsonObject output); + void heartbeat_json(JsonObject output); void send_heartbeat(); void send_info_mqtt(); diff --git a/src/temperaturesensor.cpp b/src/temperaturesensor.cpp index 4e3c268e5..5746885bb 100644 --- a/src/temperaturesensor.cpp +++ b/src/temperaturesensor.cpp @@ -414,8 +414,8 @@ bool TemperatureSensor::get_value_info(JsonObject output, const char * cmd, cons if (Helpers::toLower(command_s) == Helpers::toLower(sensor.name().c_str()) || Helpers::toLower(command_s) == Helpers::toLower(sensor.id().c_str())) { output["id"] = sensor.id(); output["name"] = sensor.name(); - char val[10]; if (Helpers::hasValue(sensor.temperature_c)) { + char val[10]; output["value"] = serialized(Helpers::render_value(val, sensor.temperature_c, 10, EMSESP::system_.fahrenheit() ? 2 : 0)); }