From bb17885b4ac2b5f974e580c86165cc295d0b4390 Mon Sep 17 00:00:00 2001 From: Yegor Vialov Date: Sun, 4 Nov 2018 21:02:12 +0200 Subject: [PATCH] Resolves #163 Location title --- lib/home_assistant.class.dart | 12 +++++++++--- lib/ui_class/ui.dart | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/home_assistant.class.dart b/lib/home_assistant.class.dart index 9d28090..8c89e85 100644 --- a/lib/home_assistant.class.dart +++ b/lib/home_assistant.class.dart @@ -40,7 +40,13 @@ class HomeAssistant { Duration fetchTimeout = Duration(seconds: 30); Duration connectTimeout = Duration(seconds: 15); - String get locationName => _instanceConfig["location_name"] ?? ""; + String get locationName { + if (_useLovelace) { + return ui?.title ?? ""; + } else { + return _instanceConfig["location_name"] ?? ""; + } + } String get userName => _userName ?? locationName; String get userAvatarText => userName.length > 0 ? userName[0] : ""; //int get viewsCount => entities.views.length ?? 0; @@ -376,8 +382,8 @@ class HomeAssistant { } void _parseLovelace() { - ui = HomeAssistantUI(); TheLogger.debug("--Title: ${_rawLovelaceData["title"]}"); + ui.title = _rawLovelaceData["title"]; int viewCounter = 0; TheLogger.debug("--Views count: ${_rawLovelaceData['views'].length}"); _rawLovelaceData["views"].forEach((rawView){ @@ -437,12 +443,12 @@ class HomeAssistant { } void _createUI() { + ui = HomeAssistantUI(); if ((_useLovelace) && (_rawLovelaceData != null)) { TheLogger.debug("Creating Lovelace UI"); _parseLovelace(); } else { TheLogger.debug("Creating group-based UI"); - ui = HomeAssistantUI(); int viewCounter = 0; if (!entities.hasDefaultView) { HAView view = HAView( diff --git a/lib/ui_class/ui.dart b/lib/ui_class/ui.dart index c4f5a54..f34acae 100644 --- a/lib/ui_class/ui.dart +++ b/lib/ui_class/ui.dart @@ -2,6 +2,7 @@ part of '../main.dart'; class HomeAssistantUI { List views; + String title; HomeAssistantUI() { views = [];