Skip to content

Commit a6b0c74

Browse files
committed
add message "no entries" to analog/temperature/custom/sccheduler
1 parent 09e2945 commit a6b0c74

4 files changed

+15
-11
lines changed

src/analogsensor.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ void AnalogSensor::publish_values(const bool force) {
625625
// searches by name
626626
bool AnalogSensor::get_value_info(JsonObject & output, const char * cmd, const int8_t id) const {
627627
if (sensors_.empty()) {
628+
output["message"] = "no entries";
628629
return false;
629630
}
630631
// 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
686687
// returns false if there are no sensors
687688
bool AnalogSensor::command_info(const char * value, const int8_t id, JsonObject & output) const {
688689
if (sensors_.empty()) {
689-
return false;
690+
output["message"] = "no entries";
691+
return true;
690692
}
691693

692694
for (const auto & sensor : sensors_) {

src/temperaturesensor.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ bool TemperatureSensor::command_commands(const char * value, const int8_t id, Js
363363
// returns false if there are no sensors
364364
bool TemperatureSensor::command_info(const char * value, const int8_t id, JsonObject & output) {
365365
if (sensors_.empty()) {
366-
return false;
366+
output["message"] = "no entries";
367+
return true;
367368
}
368369

369370
for (const auto & sensor : sensors_) {
@@ -389,6 +390,7 @@ bool TemperatureSensor::command_info(const char * value, const int8_t id, JsonOb
389390
// called from emsesp.cpp, similar to the emsdevice->get_value_info
390391
bool TemperatureSensor::get_value_info(JsonObject & output, const char * cmd, const int8_t id) {
391392
if (sensors_.empty()) {
393+
output["message"] = "no entries";
392394
return false;
393395
}
394396
// make a copy of the string command for parsing
@@ -576,7 +578,7 @@ TemperatureSensor::Sensor::Sensor(const uint8_t addr[])
576578
(unsigned int)(internal_id_ >> 48) & 0xFF,
577579
(unsigned int)(internal_id_ >> 32) & 0xFFFF,
578580
(unsigned int)(internal_id_ >> 16) & 0xFFFF,
579-
(unsigned int)(internal_id_) & 0xFFFF);
581+
(unsigned int)(internal_id_)&0xFFFF);
580582
id_ = std::string(id_s);
581583
name_ = std::string{}; // name (alias) is empty
582584
offset_ = 0; // 0 degrees offset

src/web/WebEntityService.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,17 @@ bool WebEntityService::get_value_info(JsonObject & output, const char * cmd) {
225225
}
226226
return true;
227227
}
228+
if (entityItems->size() == 0) {
229+
output["message"] = "no entries";
230+
return true;
231+
}
228232
if (strlen(cmd) == 0 || Helpers::toLower(cmd) == F_(values) || Helpers::toLower(cmd) == F_(info)) {
229233
// list all names
230234
for (const EntityItem & entity : *entityItems) {
231235
render_value(output, entity);
232236
}
233237
return (output.size() != 0);
234238
}
235-
if (entityItems->size() == 0) {
236-
output["message"] = "no custom entities";
237-
return false;
238-
}
239239
char command_s[30];
240240
strlcpy(command_s, cmd, sizeof(command_s));
241241
char * attribute_s = nullptr;

src/web/WebSchedulerService.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ bool WebSchedulerService::get_value_info(JsonObject & output, const char * cmd)
142142
}
143143
return true;
144144
}
145+
if (scheduleItems->size() == 0) {
146+
output["message"] = "no entries";
147+
return true;
148+
}
145149
if (strlen(cmd) == 0 || Helpers::toLower(cmd) == F_(values) || Helpers::toLower(cmd) == F_(info)) {
146150
// list all names
147151
for (const ScheduleItem & scheduleItem : *scheduleItems) {
@@ -158,10 +162,6 @@ bool WebSchedulerService::get_value_info(JsonObject & output, const char * cmd)
158162
}
159163
return (output.size() > 0);
160164
}
161-
if (scheduleItems->size() == 0) {
162-
output["message"] = "no schedules";
163-
return false;
164-
}
165165
char command_s[30];
166166
strlcpy(command_s, cmd, sizeof(command_s));
167167
char * attribute_s = nullptr;

0 commit comments

Comments
 (0)