show scheduler/custom always

This commit is contained in:
MichaelDvP
2023-09-17 09:22:25 +02:00
parent 7310db6426
commit 9d3456cb3a
4 changed files with 36 additions and 34 deletions

View File

@@ -217,24 +217,25 @@ void WebEntityService::render_value(JsonObject & output, EntityItem entity, cons
// process json output for info/commands and value_info
bool WebEntityService::get_value_info(JsonObject & output, const char * cmd) {
EMSESP::webEntityService.read([&](WebEntity & webEntity) { entityItems = &webEntity.entityItems; });
if (entityItems->size() == 0) {
return false;
}
if (Helpers::toLower(cmd) == "commands") {
output["info"] = "list all values";
output["commands"] = "list all commands";
if (Helpers::toLower(cmd) == F_(commands)) {
output[F_(info)] = Helpers::translated_word(FL_(info_cmd));
output[F_(commands)] = Helpers::translated_word(FL_(commands_cmd));
for (const auto & entity : *entityItems) {
output[entity.name] = "custom entitiy";
}
return true;
}
if (strlen(cmd) == 0 || Helpers::toLower(cmd) == "values" || Helpers::toLower(cmd) == "info") {
if (strlen(cmd) == 0 || Helpers::toLower(cmd) == F_(values) || Helpers::toLower(cmd) == F_(info)) {
// list all names
for (const EntityItem & entity : *entityItems) {
render_value(output, entity);
}
return (output.size() != 0);
}
if (entityItems->size() == 0) {
output["message"] = "no custom entities";
return false;
}
char command_s[30];
strlcpy(command_s, cmd, sizeof(command_s));
char * attribute_s = nullptr;

View File

@@ -132,12 +132,9 @@ bool WebSchedulerService::command_setvalue(const char * value, const std::string
// process json output for info/commands and value_info
bool WebSchedulerService::get_value_info(JsonObject & output, const char * cmd) {
EMSESP::webSchedulerService.read([&](WebScheduler & webScheduler) { scheduleItems = &webScheduler.scheduleItems; });
if (scheduleItems->size() == 0) {
return false;
}
if (Helpers::toLower(cmd) == "commands") {
output["info"] = "lists all values";
output["commands"] = "lists all commands";
if (Helpers::toLower(cmd) == F_(commands)) {
output[F_(info)] = Helpers::translated_word(FL_(info_cmd));
output[F_(commands)] = Helpers::translated_word(FL_(commands_cmd));
for (const ScheduleItem & scheduleItem : *scheduleItems) {
if (!scheduleItem.name.empty()) {
output[scheduleItem.name] = "activate schedule";
@@ -145,7 +142,7 @@ bool WebSchedulerService::get_value_info(JsonObject & output, const char * cmd)
}
return true;
}
if (strlen(cmd) == 0 || Helpers::toLower(cmd) == "values" || Helpers::toLower(cmd) == "info") {
if (strlen(cmd) == 0 || Helpers::toLower(cmd) == F_(values) || Helpers::toLower(cmd) == F_(info)) {
// list all names
for (const ScheduleItem & scheduleItem : *scheduleItems) {
if (!scheduleItem.name.empty()) {
@@ -161,6 +158,10 @@ bool WebSchedulerService::get_value_info(JsonObject & output, const char * cmd)
}
return (output.size() > 0);
}
if (scheduleItems->size() == 0) {
output["message"] = "no schedules";
return false;
}
char command_s[30];
strlcpy(command_s, cmd, sizeof(command_s));
char * attribute_s = nullptr;