"no entries" is valid command execution

This commit is contained in:
MichaelDvP
2023-09-19 14:22:38 +02:00
parent 42a4c792ad
commit 8b136ddefe
4 changed files with 7 additions and 8 deletions

View File

@@ -626,7 +626,7 @@ void AnalogSensor::publish_values(const bool force) {
bool AnalogSensor::get_value_info(JsonObject & output, const char * cmd, const int8_t id) const { bool AnalogSensor::get_value_info(JsonObject & output, const char * cmd, const int8_t id) const {
if (sensors_.empty()) { if (sensors_.empty()) {
output["message"] = "no entries"; output["message"] = "no entries";
return false; return true;
} }
// make a copy of the string command for parsing // make a copy of the string command for parsing
char command_s[30]; char command_s[30];

View File

@@ -927,15 +927,12 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
if (telegram->type_id == publish_id_) { if (telegram->type_id == publish_id_) {
publish_id_ = 0; publish_id_ = 0;
} }
// dont publish if not connected and don't reset flag, so publish is done after reconnect
if (Mqtt::connected()) {
emsdevice->has_update(false); // reset flag emsdevice->has_update(false); // reset flag
if (!Mqtt::publish_single()) { if (!Mqtt::publish_single()) {
publish_device_values(emsdevice->device_type()); // publish to MQTT if we explicitly have too publish_device_values(emsdevice->device_type()); // publish to MQTT if we explicitly have too
} }
} }
} }
}
if (wait_validate_ == telegram->type_id) { if (wait_validate_ == telegram->type_id) {
wait_validate_ = 0; wait_validate_ = 0;
} }

View File

@@ -391,7 +391,7 @@ bool TemperatureSensor::command_info(const char * value, const int8_t id, JsonOb
bool TemperatureSensor::get_value_info(JsonObject & output, const char * cmd, const int8_t id) { bool TemperatureSensor::get_value_info(JsonObject & output, const char * cmd, const int8_t id) {
if (sensors_.empty()) { if (sensors_.empty()) {
output["message"] = "no entries"; output["message"] = "no entries";
return false; return true;
} }
// make a copy of the string command for parsing // make a copy of the string command for parsing
char command_s[30]; char command_s[30];

View File

@@ -269,11 +269,13 @@ bool WebEntityService::get_value_info(JsonObject & output, const char * cmd) {
JsonVariant data = output[attribute_s]; JsonVariant data = output[attribute_s];
output.clear(); output.clear();
output["api_data"] = data; output["api_data"] = data;
return true;
} else { } else {
char error[100]; char error[100];
snprintf(error, sizeof(error), "cannot find attribute %s in entity %s", attribute_s, command_s); snprintf(error, sizeof(error), "cannot find attribute %s in entity %s", attribute_s, command_s);
output.clear(); output.clear();
output["message"] = error; output["message"] = error;
return false;
} }
} }
} }