From b4d4c5abecd648eeb1991a233d51636c7ca470ae Mon Sep 17 00:00:00 2001 From: Yegor Vialov Date: Thu, 13 Dec 2018 23:40:20 +0200 Subject: [PATCH] Relates to #248 old format support --- lib/home_assistant.class.dart | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/home_assistant.class.dart b/lib/home_assistant.class.dart index a372913..dbf1d04 100644 --- a/lib/home_assistant.class.dart +++ b/lib/home_assistant.class.dart @@ -453,9 +453,14 @@ class HomeAssistant { String tapAction = EntityTapAction.moreInfo; String holdAction = EntityTapAction.none; if (card.type == CardType.glance || card.type == CardType.entityButton) { - if (rawEntity["tap_action"] != null && !(rawEntity["tap_action"] is String)) { - tapAction = rawEntity["tap_action"]["action"]; - holdAction = rawEntity["hold_action"]["action"]; + if (rawEntity["tap_action"] != null) { + if (rawEntity["tap_action"] is String) { + tapAction = rawEntity["tap_action"]; + holdAction = rawEntity["hold_action"]; + } else { + tapAction = rawEntity["tap_action"]["action"]; + holdAction = rawEntity["hold_action"]["action"]; + } } } card.entities.add( @@ -476,9 +481,14 @@ class HomeAssistant { var en = rawCard["entity"]; String tapAction = EntityTapAction.moreInfo; String holdAction = EntityTapAction.none; - if (rawCard["tap_action"] != null && !(rawCard["tap_action"] is String)) { - tapAction = rawCard["tap_action"]["action"]; - holdAction = rawCard["hold_action"]["action"]; + if (rawCard["tap_action"] != null) { + if (rawCard["tap_action"] is String) { + tapAction = rawCard["tap_action"]; + holdAction = rawCard["hold_action"]; + } else { + tapAction = rawCard["tap_action"]["action"]; + holdAction = rawCard["hold_action"]["action"]; + } } if (en is String) { if (entities.isExist(en)) {