From f2d9a4f071029d7d475e0180a123b24cfda18655 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 15 Nov 2015 00:36:35 -0800 Subject: [PATCH] Do not color icon if too white --- src/components/entity/state-badge.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/entity/state-badge.js b/src/components/entity/state-badge.js index 53ad82d2e0..a4058545d7 100644 --- a/src/components/entity/state-badge.js +++ b/src/components/entity/state-badge.js @@ -16,9 +16,11 @@ export default new Polymer({ * Called when an attribute changes that influences the color of the icon. */ updateIconColor(newVal) { - // for domain light, set color of icon to light color if available + // for domain light, set color of icon to light color if available and it is + // not very white (sum rgb colors < 730) if (newVal.domain === 'light' && newVal.state === 'on' && - newVal.attributes.rgb_color) { + newVal.attributes.rgb_color && + newVal.attributes.rgb_color.reduce((cur, tot) => cur + tot, 0) < 730) { this.$.icon.style.color = 'rgb(' + newVal.attributes.rgb_color.join(',') + ')'; } else { this.$.icon.style.color = null;