From 662b44d4432093448228b34b30ff969227b86095 Mon Sep 17 00:00:00 2001 From: estevez Date: Tue, 25 Sep 2018 23:14:33 +0300 Subject: [PATCH] CHeck if entity for card has attributes --- lib/data_provider.class.dart | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/data_provider.class.dart b/lib/data_provider.class.dart index acca5f2..3549e8f 100644 --- a/lib/data_provider.class.dart +++ b/lib/data_provider.class.dart @@ -296,18 +296,18 @@ class HADataProvider { } } } else { - newGroup["entity_id"] = entityId; - newGroup["friendly_name"] = - (cardOrEntityData['attributes'] != null) - ? (cardOrEntityData['attributes']['friendly_name'] ?? - "") - : ""; - newGroup["children"] = List(); - cardOrEntityData["attributes"]["entity_id"].forEach(( - groupedEntityId) { - newGroup["children"].add(groupedEntityId); - }); - viewStructure["groups"]["$entityId"] = Map.from(newGroup); + if (cardOrEntityData["attributes"] != null) { + newGroup["entity_id"] = entityId; + newGroup["friendly_name"] = cardOrEntityData['attributes']['friendly_name'] ?? ""; + newGroup["children"] = List(); + cardOrEntityData["attributes"]["entity_id"].forEach(( + groupedEntityId) { + newGroup["children"].add(groupedEntityId); + }); + viewStructure["groups"]["$entityId"] = Map.from(newGroup); + } else { + TheLogger.log("Warning", "Group has no attributes to build a card: $entityId"); + } } } else { TheLogger.log("Warning", "Unknown entity inside view: $entityId");