Migrate light to use RGB instead of XY color

This commit is contained in:
Paulus Schoutsen
2015-11-07 00:55:00 -08:00
parent b04e285061
commit 5ea83557bb
5 changed files with 6 additions and 42 deletions

View File

@@ -1,7 +1,5 @@
import Polymer from '../../polymer';
import xyBriToRgb from '../../util/xybri-to-rgb';
require('./domain-icon');
export default new Polymer({
@@ -20,11 +18,8 @@ export default new Polymer({
updateIconColor(newVal) {
// for domain light, set color of icon to light color if available
if (newVal.domain === 'light' && newVal.state === 'on' &&
newVal.attributes.brightness && newVal.attributes.xy_color) {
const rgb = xyBriToRgb(newVal.attributes.xy_color[0],
newVal.attributes.xy_color[1],
newVal.attributes.brightness);
this.$.icon.style.color = 'rgb(' + rgb.map(Math.floor).join(',') + ')';
newVal.attributes.rgb_color) {
this.$.icon.style.color = 'rgb(' + newVal.attributes.rgb_color.join(',') + ')';
} else {
this.$.icon.style.color = null;
}

View File

@@ -1,7 +1,5 @@
import Polymer from '../../polymer';
import xyBriToRgb from '../../util/xybri-to-rgb';
require('./ha-state-icon');
export default new Polymer({
@@ -20,11 +18,8 @@ export default new Polymer({
updateIconColor(newVal) {
// for domain light, set color of icon to light color if available
if (newVal.domain === 'light' && newVal.state === 'on' &&
newVal.attributes.brightness && newVal.attributes.xy_color) {
const rgb = xyBriToRgb(newVal.attributes.xy_color[0],
newVal.attributes.xy_color[1],
newVal.attributes.brightness);
this.$.icon.style.color = 'rgb(' + rgb.map(Math.floor).join(',') + ')';
newVal.attributes.rgb_color) {
this.$.icon.style.color = 'rgb(' + newVal.attributes.rgb_color.join(',') + ')';
} else {
this.$.icon.style.color = null;
}