Get color from rgb_color if there is no hsv_color attribute

This commit is contained in:
estevez-dev 2019-02-22 14:20:01 +02:00
parent eb7d17d147
commit 0615073ec4
3 changed files with 6 additions and 3 deletions

View File

@ -45,11 +45,14 @@ class LightEntity extends Entity {
HSVColor _getColor() { HSVColor _getColor() {
List hs = attributes["hs_color"]; List hs = attributes["hs_color"];
List rgb = attributes["rgb_color"];
try { try {
if ((hs != null) && (hs.length > 0)) { if (hs != null && hs.isNotEmpty) {
double sat = hs[1]/100; double sat = hs[1]/100;
String ssat = sat.toStringAsFixed(2); String ssat = sat.toStringAsFixed(2);
return HSVColor.fromAHSV(1.0, hs[0], double.parse(ssat), 1.0); 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 { } else {
return null; return null;
} }

View File

@ -94,7 +94,7 @@ part 'ui_widgets/card_header_widget.dart';
EventBus eventBus = new EventBus(); EventBus eventBus = new EventBus();
const String appName = "HA Client"; const String appName = "HA Client";
const appVersion = "0.4.4"; const appVersion = "0.4.5";
String homeAssistantWebHost; String homeAssistantWebHost;

View File

@ -1,7 +1,7 @@
name: hass_client name: hass_client
description: Home Assistant Android Client description: Home Assistant Android Client
version: 0.4.4+95 version: 0.4.5+96
environment: environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0" sdk: ">=2.0.0-dev.68.0 <3.0.0"