diff --git a/interface/src/project/SettingsCustomization.tsx b/interface/src/project/SettingsCustomization.tsx index 14a0ceb43..e9c6cedb8 100644 --- a/interface/src/project/SettingsCustomization.tsx +++ b/interface/src/project/SettingsCustomization.tsx @@ -116,28 +116,24 @@ const SettingsCustomization: FC = () => { return ( <> - - Select a device and customize each entity using the options: - -   + + Select a device and customize each of its entities using the options: +  mark it as favorite to be listed at the top of the Dashboard - -   - -  hide from the Dashboard - - -   + -  make it read-only (if it has write operation available) +  make it read-only, only if it has write operation available - -   +  excluded it from MQTT and API outputs + + +  hide it from the Dashboard + { }; return ( - +
OPTIONS @@ -227,7 +223,7 @@ const SettingsCustomization: FC = () => { {deviceEntities.map((de) => ( - + { } }) +function myF(entity, de, dd) { + const name = entity.slice(2) + const mask = parseInt(entity.slice(0, 2), 16) + const mask_hex = entity.slice(0, 2) + + objIndex = de.findIndex((obj) => obj.s == name) + if (objIndex !== -1) { + de[objIndex].m = mask + const fullname = de[objIndex].n + objIndex = dd.data.findIndex((obj) => obj.n.slice(2) == fullname) + if (objIndex !== -1) { + dd.data[objIndex].n = mask_hex + fullname + console.log('Updating: ') + console.log(dd.data[objIndex]) + } else { + console.log("can't locate record for " + fullname) + } + } else { + console.log("can't locate record for id " + id) + } +} + rest_server.post(EMSESP_MASKED_ENTITIES_ENDPOINT, (req, res) => { - console.log('list for unique id ' + req.body.id + ' and entities:') - console.log(req.body.entity_ids) + const id = req.body.id + for (const entity of req.body.entity_ids) { + if (id === 1) { + myF(entity, emsesp_deviceentities_1, emsesp_devicedata_1) + } else if (id === 2) { + myF(entity, emsesp_deviceentities_2, emsesp_devicedata_2) + } else if (id === 4) { + myF(entity, emsesp_deviceentities_4, emsesp_devicedata_4) + } + } res.sendStatus(200) }) diff --git a/src/web/WebCustomizationService.cpp b/src/web/WebCustomizationService.cpp index 89cc6af8a..8c81d172c 100644 --- a/src/web/WebCustomizationService.cpp +++ b/src/web/WebCustomizationService.cpp @@ -171,6 +171,7 @@ void WebCustomizationService::devices(AsyncWebServerRequest * request) { JsonObject obj = devices.createNestedObject(); obj["i"] = emsdevice->unique_id(); // a unique id + /* // shortname - we prefix the count to make it unique uint8_t device_index = EMSESP::device_index(emsdevice->device_type(), emsdevice->unique_id()); if (device_index) { @@ -179,6 +180,8 @@ void WebCustomizationService::devices(AsyncWebServerRequest * request) { } else { obj["s"] = emsdevice->device_type_name() + " (" + emsdevice->name() + ")"; } + */ + obj["s"] = emsdevice->device_type_name() + " (" + emsdevice->name() + ")"; } }