mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-10-28 11:14:58 +00:00
This commit is contained in:
@@ -350,11 +350,16 @@ void WebCustomizationService::customization_entities(AsyncWebServerRequest * req
|
||||
// get list of entities that have masks set or a custom fullname
|
||||
emsdevice->getCustomizationEntities(entity_ids);
|
||||
|
||||
// Save the list to the customization file
|
||||
// Save the list to the customization file.
|
||||
// The same record holds the device custom name and brand, so keep those when replacing the entity list.
|
||||
update([&](WebCustomization & settings) {
|
||||
// see if we already have a mask list for this device, if so remove the entry
|
||||
std::string custom_name;
|
||||
std::string custom_brand;
|
||||
|
||||
for (auto it = settings.entityCustomizations.begin(); it != settings.entityCustomizations.end();) {
|
||||
if ((*it).product_id == product_id && (*it).device_id == device_id) {
|
||||
custom_name = (*it).custom_name;
|
||||
custom_brand = (*it).custom_brand;
|
||||
it = settings.entityCustomizations.erase(it);
|
||||
break;
|
||||
} else {
|
||||
@@ -362,10 +367,11 @@ void WebCustomizationService::customization_entities(AsyncWebServerRequest * req
|
||||
}
|
||||
}
|
||||
|
||||
// re-create a new entry
|
||||
EntityCustomization new_entry;
|
||||
new_entry.product_id = product_id;
|
||||
new_entry.device_id = device_id;
|
||||
new_entry.custom_name = custom_name;
|
||||
new_entry.custom_brand = custom_brand;
|
||||
new_entry.entity_ids = entity_ids;
|
||||
settings.entityCustomizations.push_back(new_entry);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user