mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
show sensor command commands
This commit is contained in:
@@ -623,6 +623,11 @@ void AnalogSensor::publish_values(const bool force) {
|
|||||||
// called from emsesp.cpp for commands
|
// called from emsesp.cpp for commands
|
||||||
// searches sensor by name
|
// searches sensor by name
|
||||||
bool AnalogSensor::get_value_info(JsonObject output, const char * cmd, const int8_t id) {
|
bool AnalogSensor::get_value_info(JsonObject output, const char * cmd, const int8_t id) {
|
||||||
|
// check of it a 'commmands' command
|
||||||
|
if (Helpers::toLower(cmd) == F_(commands)) {
|
||||||
|
return Command::list(EMSdevice::DeviceType::ANALOGSENSOR, output);
|
||||||
|
}
|
||||||
|
|
||||||
if (sensors_.empty()) {
|
if (sensors_.empty()) {
|
||||||
return true; // no sensors, return true
|
return true; // no sensors, return true
|
||||||
}
|
}
|
||||||
@@ -647,11 +652,6 @@ bool AnalogSensor::get_value_info(JsonObject output, const char * cmd, const int
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check of it a 'commmands' command
|
|
||||||
if (Helpers::toLower(cmd) == F_(commands)) {
|
|
||||||
return Command::list(EMSdevice::DeviceType::TEMPERATURESENSOR, output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// this is for a specific sensor
|
// this is for a specific sensor
|
||||||
// make a copy of the string command for parsing, and lowercase it
|
// make a copy of the string command for parsing, and lowercase it
|
||||||
char sensor_name[30] = {'\0'};
|
char sensor_name[30] = {'\0'};
|
||||||
|
|||||||
@@ -439,7 +439,11 @@ void Command::erase_command(const uint8_t device_type, const char * cmd) {
|
|||||||
|
|
||||||
// list all commands for a specific device, output as json
|
// list all commands for a specific device, output as json
|
||||||
bool Command::list(const uint8_t device_type, JsonObject output) {
|
bool Command::list(const uint8_t device_type, JsonObject output) {
|
||||||
if (cmdfunctions_.empty()) {
|
// force add info and commands for those non-EMS devices
|
||||||
|
if (device_type == EMSdevice::DeviceType::TEMPERATURESENSOR || device_type == EMSdevice::DeviceType::ANALOGSENSOR) {
|
||||||
|
output[F_(info)] = Helpers::translated_word(FL_(info_cmd));
|
||||||
|
output[F_(commands)] = Helpers::translated_word(FL_(commands_cmd));
|
||||||
|
} else if (cmdfunctions_.empty()) {
|
||||||
output["message"] = "no commands available";
|
output["message"] = "no commands available";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -453,12 +457,6 @@ bool Command::list(const uint8_t device_type, JsonObject output) {
|
|||||||
}
|
}
|
||||||
sorted_cmds.sort();
|
sorted_cmds.sort();
|
||||||
|
|
||||||
// force add info and commands for those non-EMS devices
|
|
||||||
if (device_type == EMSdevice::DeviceType::TEMPERATURESENSOR) {
|
|
||||||
output[F_(info)] = Helpers::translated_word(FL_(info_cmd));
|
|
||||||
output[F_(commands)] = Helpers::translated_word(FL_(commands_cmd));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto & cl : sorted_cmds) {
|
for (const auto & cl : sorted_cmds) {
|
||||||
for (const auto & cf : cmdfunctions_) {
|
for (const auto & cf : cmdfunctions_) {
|
||||||
if ((cf.device_type_ == device_type) && !cf.has_flags(CommandFlag::HIDDEN) && cf.description_ && (cl == std::string(cf.cmd_))) {
|
if ((cf.device_type_ == device_type) && !cf.has_flags(CommandFlag::HIDDEN) && cf.description_ && (cl == std::string(cf.cmd_))) {
|
||||||
|
|||||||
@@ -345,6 +345,11 @@ bool TemperatureSensor::updated_values() {
|
|||||||
|
|
||||||
// called from emsesp.cpp for commands
|
// called from emsesp.cpp for commands
|
||||||
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) {
|
||||||
|
// check of it a 'commmands' command
|
||||||
|
if (Helpers::toLower(cmd) == F_(commands)) {
|
||||||
|
return Command::list(EMSdevice::DeviceType::TEMPERATURESENSOR, output);
|
||||||
|
}
|
||||||
|
|
||||||
if (sensors_.empty()) {
|
if (sensors_.empty()) {
|
||||||
return true; // no sensors, return true
|
return true; // no sensors, return true
|
||||||
}
|
}
|
||||||
@@ -372,11 +377,6 @@ bool TemperatureSensor::get_value_info(JsonObject output, const char * cmd, cons
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check of it a 'commmands' command
|
|
||||||
if (Helpers::toLower(cmd) == F_(commands)) {
|
|
||||||
return Command::list(EMSdevice::DeviceType::TEMPERATURESENSOR, output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// this is for a specific sensor
|
// this is for a specific sensor
|
||||||
// make a copy of the string command for parsing, and lowercase it
|
// make a copy of the string command for parsing, and lowercase it
|
||||||
char sensor_name[30] = {'\0'};
|
char sensor_name[30] = {'\0'};
|
||||||
|
|||||||
Reference in New Issue
Block a user