Fix display name getting issue

This commit is contained in:
Yegor Vialov 2020-05-25 08:52:16 +00:00
parent 9b5a0068fd
commit b1e5e73278

View File

@ -78,9 +78,21 @@ class Entity {
chartType: EntityHistoryWidgetType.simple
);
String get displayName =>
attributes["friendly_name"] ??
(attributes["name"] ?? (entityId != null && entityId.contains('.')) ? entityId.split(".")[1].replaceAll("_", " ") : "");
String get displayName {
if (attributes.containsKey('friendly_name')) {
return attributes['friendly_name'];
}
if (attributes.containsKey('name')) {
return attributes['name'];
}
if (entityId == null) {
return "";
}
if (entityId.contains(".")) {
return entityId.split(".")[1].replaceAll("_", " ");
}
return entityId;
}
bool get isView =>
(domain == "group") &&