mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
add message "no entries" to analog/temperature/custom/sccheduler
This commit is contained in:
@@ -625,6 +625,7 @@ void AnalogSensor::publish_values(const bool force) {
|
|||||||
// searches by name
|
// searches by name
|
||||||
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";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// make a copy of the string command for parsing
|
// make a copy of the string command for parsing
|
||||||
@@ -686,7 +687,8 @@ bool AnalogSensor::get_value_info(JsonObject & output, const char * cmd, const i
|
|||||||
// returns false if there are no sensors
|
// returns false if there are no sensors
|
||||||
bool AnalogSensor::command_info(const char * value, const int8_t id, JsonObject & output) const {
|
bool AnalogSensor::command_info(const char * value, const int8_t id, JsonObject & output) const {
|
||||||
if (sensors_.empty()) {
|
if (sensors_.empty()) {
|
||||||
return false;
|
output["message"] = "no entries";
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto & sensor : sensors_) {
|
for (const auto & sensor : sensors_) {
|
||||||
|
|||||||
@@ -363,7 +363,8 @@ bool TemperatureSensor::command_commands(const char * value, const int8_t id, Js
|
|||||||
// returns false if there are no sensors
|
// returns false if there are no sensors
|
||||||
bool TemperatureSensor::command_info(const char * value, const int8_t id, JsonObject & output) {
|
bool TemperatureSensor::command_info(const char * value, const int8_t id, JsonObject & output) {
|
||||||
if (sensors_.empty()) {
|
if (sensors_.empty()) {
|
||||||
return false;
|
output["message"] = "no entries";
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto & sensor : sensors_) {
|
for (const auto & sensor : sensors_) {
|
||||||
@@ -389,6 +390,7 @@ bool TemperatureSensor::command_info(const char * value, const int8_t id, JsonOb
|
|||||||
// called from emsesp.cpp, similar to the emsdevice->get_value_info
|
// called from emsesp.cpp, similar to the emsdevice->get_value_info
|
||||||
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";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// make a copy of the string command for parsing
|
// make a copy of the string command for parsing
|
||||||
@@ -576,7 +578,7 @@ TemperatureSensor::Sensor::Sensor(const uint8_t addr[])
|
|||||||
(unsigned int)(internal_id_ >> 48) & 0xFF,
|
(unsigned int)(internal_id_ >> 48) & 0xFF,
|
||||||
(unsigned int)(internal_id_ >> 32) & 0xFFFF,
|
(unsigned int)(internal_id_ >> 32) & 0xFFFF,
|
||||||
(unsigned int)(internal_id_ >> 16) & 0xFFFF,
|
(unsigned int)(internal_id_ >> 16) & 0xFFFF,
|
||||||
(unsigned int)(internal_id_) & 0xFFFF);
|
(unsigned int)(internal_id_)&0xFFFF);
|
||||||
id_ = std::string(id_s);
|
id_ = std::string(id_s);
|
||||||
name_ = std::string{}; // name (alias) is empty
|
name_ = std::string{}; // name (alias) is empty
|
||||||
offset_ = 0; // 0 degrees offset
|
offset_ = 0; // 0 degrees offset
|
||||||
|
|||||||
@@ -225,6 +225,10 @@ bool WebEntityService::get_value_info(JsonObject & output, const char * cmd) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (entityItems->size() == 0) {
|
||||||
|
output["message"] = "no entries";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (strlen(cmd) == 0 || Helpers::toLower(cmd) == F_(values) || Helpers::toLower(cmd) == F_(info)) {
|
if (strlen(cmd) == 0 || Helpers::toLower(cmd) == F_(values) || Helpers::toLower(cmd) == F_(info)) {
|
||||||
// list all names
|
// list all names
|
||||||
for (const EntityItem & entity : *entityItems) {
|
for (const EntityItem & entity : *entityItems) {
|
||||||
@@ -232,10 +236,6 @@ bool WebEntityService::get_value_info(JsonObject & output, const char * cmd) {
|
|||||||
}
|
}
|
||||||
return (output.size() != 0);
|
return (output.size() != 0);
|
||||||
}
|
}
|
||||||
if (entityItems->size() == 0) {
|
|
||||||
output["message"] = "no custom entities";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
char command_s[30];
|
char command_s[30];
|
||||||
strlcpy(command_s, cmd, sizeof(command_s));
|
strlcpy(command_s, cmd, sizeof(command_s));
|
||||||
char * attribute_s = nullptr;
|
char * attribute_s = nullptr;
|
||||||
|
|||||||
@@ -142,6 +142,10 @@ bool WebSchedulerService::get_value_info(JsonObject & output, const char * cmd)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (scheduleItems->size() == 0) {
|
||||||
|
output["message"] = "no entries";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (strlen(cmd) == 0 || Helpers::toLower(cmd) == F_(values) || Helpers::toLower(cmd) == F_(info)) {
|
if (strlen(cmd) == 0 || Helpers::toLower(cmd) == F_(values) || Helpers::toLower(cmd) == F_(info)) {
|
||||||
// list all names
|
// list all names
|
||||||
for (const ScheduleItem & scheduleItem : *scheduleItems) {
|
for (const ScheduleItem & scheduleItem : *scheduleItems) {
|
||||||
@@ -158,10 +162,6 @@ bool WebSchedulerService::get_value_info(JsonObject & output, const char * cmd)
|
|||||||
}
|
}
|
||||||
return (output.size() > 0);
|
return (output.size() > 0);
|
||||||
}
|
}
|
||||||
if (scheduleItems->size() == 0) {
|
|
||||||
output["message"] = "no schedules";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
char command_s[30];
|
char command_s[30];
|
||||||
strlcpy(command_s, cmd, sizeof(command_s));
|
strlcpy(command_s, cmd, sizeof(command_s));
|
||||||
char * attribute_s = nullptr;
|
char * attribute_s = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user