From 0615073ec468440ed30be9bb783133727e2a0423 Mon Sep 17 00:00:00 2001 From: estevez-dev Date: Fri, 22 Feb 2019 14:20:01 +0200 Subject: [PATCH] Get color from rgb_color if there is no hsv_color attribute --- lib/entity_class/light_entity.class.dart | 5 ++++- lib/main.dart | 2 +- pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/entity_class/light_entity.class.dart b/lib/entity_class/light_entity.class.dart index 730279e..aaf0936 100644 --- a/lib/entity_class/light_entity.class.dart +++ b/lib/entity_class/light_entity.class.dart @@ -45,11 +45,14 @@ class LightEntity extends Entity { HSVColor _getColor() { List hs = attributes["hs_color"]; + List rgb = attributes["rgb_color"]; try { - if ((hs != null) && (hs.length > 0)) { + if (hs != null && hs.isNotEmpty) { double sat = hs[1]/100; String ssat = sat.toStringAsFixed(2); return HSVColor.fromAHSV(1.0, hs[0], double.parse(ssat), 1.0); + } else if (rgb != null && rgb.isNotEmpty) { + return HSVColor.fromColor(Color.fromARGB(255, rgb[0], rgb[1], rgb[2])); } else { return null; } diff --git a/lib/main.dart b/lib/main.dart index e17c411..21092a3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -94,7 +94,7 @@ part 'ui_widgets/card_header_widget.dart'; EventBus eventBus = new EventBus(); const String appName = "HA Client"; -const appVersion = "0.4.4"; +const appVersion = "0.4.5"; String homeAssistantWebHost; diff --git a/pubspec.yaml b/pubspec.yaml index 19148ff..5eb0ecb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: hass_client description: Home Assistant Android Client -version: 0.4.4+95 +version: 0.4.5+96 environment: sdk: ">=2.0.0-dev.68.0 <3.0.0"