use same ha_uom function to add uom, state and device class

This commit is contained in:
proddy
2025-01-22 22:31:21 +01:00
parent 5f52a646ff
commit e6f15681c0
6 changed files with 30 additions and 23 deletions

View File

@@ -325,9 +325,8 @@ void WebCustomEntityService::get_value_json(JsonObject output, CustomEntityItem
output["fullname"] = entity.name;
output["storage"] = entity.ram ? "ram" : "ems";
output["type"] = entity.value_type == DeviceValueType::BOOL ? "boolean" : entity.value_type == DeviceValueType::STRING ? "string" : F_(number);
if (entity.uom > 0) {
output["uom"] = EMSdevice::uom_to_string(entity.uom);
}
// add uom state class and device class
Mqtt::add_ha_uom(output, entity.value_type, entity.uom, nullptr, false);
output["readable"] = true;
output["writeable"] = entity.writeable;
output["visible"] = true;