This commit is contained in:
proddy
2026-10-17 15:07:25 +02:00
parent 65fb1ea299
commit 4d43307e9a
+13 -7
View File
@@ -350,23 +350,29 @@ 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) {
it = settings.entityCustomizations.erase(it);
custom_name = (*it).custom_name;
custom_brand = (*it).custom_brand;
it = settings.entityCustomizations.erase(it);
break;
} else {
++it;
}
}
// re-create a new entry
EntityCustomization new_entry;
new_entry.product_id = product_id;
new_entry.device_id = device_id;
new_entry.entity_ids = entity_ids;
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);
return StateUpdateResult::CHANGED; // save the changes