rename endpoint to entities to be consistent

This commit is contained in:
Proddy
2023-04-22 21:20:00 +02:00
parent 74c88caa19
commit 466e9ec6fe
2 changed files with 4 additions and 4 deletions

View File

@@ -36,7 +36,7 @@ void WebEntityService::begin() {
// this creates the entity file, saving it to the FS // this creates the entity file, saving it to the FS
// and also calls when the Entity web page is refreshed // and also calls when the Entity web page is refreshed
void WebEntity::read(WebEntity & webEntity, JsonObject & root) { void WebEntity::read(WebEntity & webEntity, JsonObject & root) {
JsonArray entity = root.createNestedArray("entity"); JsonArray entity = root.createNestedArray("entities");
uint8_t counter = 0; uint8_t counter = 0;
for (const EntityItem & entityItem : webEntity.entityItems) { for (const EntityItem & entityItem : webEntity.entityItems) {
JsonObject ei = entity.createNestedObject(); JsonObject ei = entity.createNestedObject();
@@ -61,8 +61,8 @@ StateUpdateResult WebEntity::update(JsonObject & root, WebEntity & webEntity) {
} }
webEntity.entityItems.clear(); webEntity.entityItems.clear();
if (root["entity"].is<JsonArray>()) { if (root["entities"].is<JsonArray>()) {
for (const JsonObject ei : root["entity"].as<JsonArray>()) { for (const JsonObject ei : root["entities"].as<JsonArray>()) {
auto entityItem = EntityItem(); auto entityItem = EntityItem();
entityItem.device_id = ei["device_id"]; // send as numeric, will be converted to string in web entityItem.device_id = ei["device_id"]; // send as numeric, will be converted to string in web
entityItem.type_id = ei["type_id"]; entityItem.type_id = ei["type_id"];

View File

@@ -21,7 +21,7 @@
#define WebEntityService_h #define WebEntityService_h
#define EMSESP_ENTITY_FILE "/config/emsespEntity.json" #define EMSESP_ENTITY_FILE "/config/emsespEntity.json"
#define EMSESP_ENTITY_SERVICE_PATH "/rest/entity" // GET and POST #define EMSESP_ENTITY_SERVICE_PATH "/rest/entities" // GET and POST
namespace emsesp { namespace emsesp {