mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
show scheduler/custom always
This commit is contained in:
@@ -23,10 +23,6 @@
|
|||||||
#include "mqtt.h"
|
#include "mqtt.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
|
||||||
#ifndef EMSESP_STANDALONE
|
|
||||||
#include "driver/adc.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <uuid/log.h>
|
#include <uuid/log.h>
|
||||||
|
|
||||||
namespace emsesp {
|
namespace emsesp {
|
||||||
|
|||||||
@@ -541,19 +541,23 @@ bool Command::device_has_commands(const uint8_t device_type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (device_type == EMSdevice::DeviceType::SCHEDULER) {
|
if (device_type == EMSdevice::DeviceType::SCHEDULER) {
|
||||||
return EMSESP::webSchedulerService.has_commands();
|
return true; // we always have info
|
||||||
|
// return EMSESP::webSchedulerService.has_commands();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device_type == EMSdevice::DeviceType::CUSTOM) {
|
if (device_type == EMSdevice::DeviceType::CUSTOM) {
|
||||||
return (EMSESP::webEntityService.count_entities() != 0);
|
return true; // we always have info
|
||||||
|
// return (EMSESP::webEntityService.count_entities() != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device_type == EMSdevice::DeviceType::TEMPERATURESENSOR) {
|
if (device_type == EMSdevice::DeviceType::TEMPERATURESENSOR) {
|
||||||
return (EMSESP::temperaturesensor_.have_sensors());
|
return true; // we always have info
|
||||||
|
// return (EMSESP::temperaturesensor_.have_sensors());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device_type == EMSdevice::DeviceType::ANALOGSENSOR) {
|
if (device_type == EMSdevice::DeviceType::ANALOGSENSOR) {
|
||||||
return (EMSESP::analogsensor_.have_sensors());
|
return EMSESP::system_.analog_enabled();
|
||||||
|
// return (EMSESP::analogsensor_.have_sensors());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto & emsdevice : EMSESP::emsdevices) {
|
for (const auto & emsdevice : EMSESP::emsdevices) {
|
||||||
@@ -574,13 +578,13 @@ bool Command::device_has_commands(const uint8_t device_type) {
|
|||||||
void Command::show_devices(uuid::console::Shell & shell) {
|
void Command::show_devices(uuid::console::Shell & shell) {
|
||||||
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::SYSTEM));
|
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::SYSTEM));
|
||||||
|
|
||||||
if (EMSESP::webSchedulerService.has_commands()) {
|
// if (EMSESP::webSchedulerService.has_commands()) {
|
||||||
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::SCHEDULER));
|
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::SCHEDULER));
|
||||||
}
|
// }
|
||||||
if (EMSESP::temperaturesensor_.have_sensors()) {
|
// if (EMSESP::temperaturesensor_.have_sensors()) {
|
||||||
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::TEMPERATURESENSOR));
|
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::TEMPERATURESENSOR));
|
||||||
}
|
// }
|
||||||
if (EMSESP::analogsensor_.have_sensors()) {
|
if (EMSESP::analogsensor_.analog_enabled()) {
|
||||||
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::ANALOGSENSOR));
|
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::ANALOGSENSOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -608,7 +612,7 @@ void Command::show_all(uuid::console::Shell & shell) {
|
|||||||
show(shell, EMSdevice::DeviceType::SYSTEM, true);
|
show(shell, EMSdevice::DeviceType::SYSTEM, true);
|
||||||
|
|
||||||
// show Custom
|
// show Custom
|
||||||
if (EMSESP::webEntityService.has_commands()) {
|
// if (EMSESP::webEntityService.has_commands()) {
|
||||||
shell.print(COLOR_BOLD_ON);
|
shell.print(COLOR_BOLD_ON);
|
||||||
shell.print(COLOR_YELLOW);
|
shell.print(COLOR_YELLOW);
|
||||||
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::CUSTOM));
|
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::CUSTOM));
|
||||||
@@ -618,10 +622,10 @@ void Command::show_all(uuid::console::Shell & shell) {
|
|||||||
shell.printf(" commands: %slists all commands %s*", COLOR_BRIGHT_CYAN, COLOR_BRIGHT_RED);
|
shell.printf(" commands: %slists all commands %s*", COLOR_BRIGHT_CYAN, COLOR_BRIGHT_RED);
|
||||||
shell.print(COLOR_RESET);
|
shell.print(COLOR_RESET);
|
||||||
show(shell, EMSdevice::DeviceType::CUSTOM, true);
|
show(shell, EMSdevice::DeviceType::CUSTOM, true);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// show scheduler
|
// show scheduler
|
||||||
if (EMSESP::webSchedulerService.has_commands()) {
|
// if (EMSESP::webSchedulerService.has_commands()) {
|
||||||
shell.print(COLOR_BOLD_ON);
|
shell.print(COLOR_BOLD_ON);
|
||||||
shell.print(COLOR_YELLOW);
|
shell.print(COLOR_YELLOW);
|
||||||
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::SCHEDULER));
|
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::SCHEDULER));
|
||||||
@@ -631,17 +635,17 @@ void Command::show_all(uuid::console::Shell & shell) {
|
|||||||
shell.printf(" commands: %slists all commands %s*", COLOR_BRIGHT_CYAN, COLOR_BRIGHT_RED);
|
shell.printf(" commands: %slists all commands %s*", COLOR_BRIGHT_CYAN, COLOR_BRIGHT_RED);
|
||||||
shell.print(COLOR_RESET);
|
shell.print(COLOR_RESET);
|
||||||
show(shell, EMSdevice::DeviceType::SCHEDULER, true);
|
show(shell, EMSdevice::DeviceType::SCHEDULER, true);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// show sensors
|
// show sensors
|
||||||
if (EMSESP::temperaturesensor_.have_sensors()) {
|
// if (EMSESP::temperaturesensor_.have_sensors()) {
|
||||||
shell.print(COLOR_BOLD_ON);
|
shell.print(COLOR_BOLD_ON);
|
||||||
shell.print(COLOR_YELLOW);
|
shell.print(COLOR_YELLOW);
|
||||||
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::TEMPERATURESENSOR));
|
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::TEMPERATURESENSOR));
|
||||||
shell.print(COLOR_RESET);
|
shell.print(COLOR_RESET);
|
||||||
show(shell, EMSdevice::DeviceType::TEMPERATURESENSOR, true);
|
show(shell, EMSdevice::DeviceType::TEMPERATURESENSOR, true);
|
||||||
}
|
// }
|
||||||
if (EMSESP::analogsensor_.have_sensors()) {
|
if (EMSESP::analogsensor_.analog_enabled()) {
|
||||||
shell.print(COLOR_BOLD_ON);
|
shell.print(COLOR_BOLD_ON);
|
||||||
shell.print(COLOR_YELLOW);
|
shell.print(COLOR_YELLOW);
|
||||||
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::ANALOGSENSOR));
|
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::ANALOGSENSOR));
|
||||||
|
|||||||
@@ -217,24 +217,25 @@ void WebEntityService::render_value(JsonObject & output, EntityItem entity, cons
|
|||||||
// process json output for info/commands and value_info
|
// process json output for info/commands and value_info
|
||||||
bool WebEntityService::get_value_info(JsonObject & output, const char * cmd) {
|
bool WebEntityService::get_value_info(JsonObject & output, const char * cmd) {
|
||||||
EMSESP::webEntityService.read([&](WebEntity & webEntity) { entityItems = &webEntity.entityItems; });
|
EMSESP::webEntityService.read([&](WebEntity & webEntity) { entityItems = &webEntity.entityItems; });
|
||||||
if (entityItems->size() == 0) {
|
if (Helpers::toLower(cmd) == F_(commands)) {
|
||||||
return false;
|
output[F_(info)] = Helpers::translated_word(FL_(info_cmd));
|
||||||
}
|
output[F_(commands)] = Helpers::translated_word(FL_(commands_cmd));
|
||||||
if (Helpers::toLower(cmd) == "commands") {
|
|
||||||
output["info"] = "list all values";
|
|
||||||
output["commands"] = "list all commands";
|
|
||||||
for (const auto & entity : *entityItems) {
|
for (const auto & entity : *entityItems) {
|
||||||
output[entity.name] = "custom entitiy";
|
output[entity.name] = "custom entitiy";
|
||||||
}
|
}
|
||||||
return true;
|
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
|
// list all names
|
||||||
for (const EntityItem & entity : *entityItems) {
|
for (const EntityItem & entity : *entityItems) {
|
||||||
render_value(output, entity);
|
render_value(output, entity);
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
|||||||
@@ -132,12 +132,9 @@ bool WebSchedulerService::command_setvalue(const char * value, const std::string
|
|||||||
// process json output for info/commands and value_info
|
// process json output for info/commands and value_info
|
||||||
bool WebSchedulerService::get_value_info(JsonObject & output, const char * cmd) {
|
bool WebSchedulerService::get_value_info(JsonObject & output, const char * cmd) {
|
||||||
EMSESP::webSchedulerService.read([&](WebScheduler & webScheduler) { scheduleItems = &webScheduler.scheduleItems; });
|
EMSESP::webSchedulerService.read([&](WebScheduler & webScheduler) { scheduleItems = &webScheduler.scheduleItems; });
|
||||||
if (scheduleItems->size() == 0) {
|
if (Helpers::toLower(cmd) == F_(commands)) {
|
||||||
return false;
|
output[F_(info)] = Helpers::translated_word(FL_(info_cmd));
|
||||||
}
|
output[F_(commands)] = Helpers::translated_word(FL_(commands_cmd));
|
||||||
if (Helpers::toLower(cmd) == "commands") {
|
|
||||||
output["info"] = "lists all values";
|
|
||||||
output["commands"] = "lists all commands";
|
|
||||||
for (const ScheduleItem & scheduleItem : *scheduleItems) {
|
for (const ScheduleItem & scheduleItem : *scheduleItems) {
|
||||||
if (!scheduleItem.name.empty()) {
|
if (!scheduleItem.name.empty()) {
|
||||||
output[scheduleItem.name] = "activate schedule";
|
output[scheduleItem.name] = "activate schedule";
|
||||||
@@ -145,7 +142,7 @@ bool WebSchedulerService::get_value_info(JsonObject & output, const char * cmd)
|
|||||||
}
|
}
|
||||||
return true;
|
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
|
// list all names
|
||||||
for (const ScheduleItem & scheduleItem : *scheduleItems) {
|
for (const ScheduleItem & scheduleItem : *scheduleItems) {
|
||||||
if (!scheduleItem.name.empty()) {
|
if (!scheduleItem.name.empty()) {
|
||||||
@@ -161,6 +158,10 @@ 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