From a3f05cb08b1aa78fa74e18d3b0770219737b2d75 Mon Sep 17 00:00:00 2001 From: Proddy Date: Sun, 17 Sep 2023 14:27:33 +0200 Subject: [PATCH] /api/custom show {} if no Custom Entities configured instead of an error #1297 --- src/command.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index 0ef48306e..5536f63ee 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -300,7 +300,7 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char * // see if there is a command registered auto cf = find_command(device_type, device_id, cmd); - // check if its a call to and end-point to a device + // check if its a call to an end-point of a device // this is used to fetch the attributes of the device entity, or call a command directly bool single_command = (!value || !strlen(value)); if (single_command) { @@ -545,7 +545,9 @@ bool Command::device_has_commands(const uint8_t device_type) { } if (device_type == EMSdevice::DeviceType::CUSTOM) { - return (EMSESP::webEntityService.count_entities() != 0); + // if there are no custom entities, don't error but return a message + return true; + // return (EMSESP::webCustomEntityService.count_entities() != 0); } if (device_type == EMSdevice::DeviceType::TEMPERATURESENSOR) { @@ -608,7 +610,7 @@ void Command::show_all(uuid::console::Shell & shell) { show(shell, EMSdevice::DeviceType::SYSTEM, true); // show Custom - if (EMSESP::webEntityService.has_commands()) { + if (EMSESP::webCustomEntityService.has_commands()) { shell.print(COLOR_BOLD_ON); shell.print(COLOR_YELLOW); shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::CUSTOM));