From bdc2b31202bb2b526a32967e724aab6470ae96a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Fri, 19 Oct 2018 12:07:33 +0200 Subject: [PATCH] Complain and ignore instead of fixing --- src/components/entity/state-badge.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/entity/state-badge.js b/src/components/entity/state-badge.js index 5c293c5261..648bd5726d 100644 --- a/src/components/entity/state-badge.js +++ b/src/components/entity/state-badge.js @@ -88,8 +88,17 @@ class StateBadge extends PolymerElement { } if (newVal.attributes.brightness) { const brightness = newVal.attributes.brightness; - // lowest brighntess will be around 50% (that's pretty dark) - iconStyle.filter = `brightness(${(parseInt(brightness) + 245) / 5}%)`; + if (typeof brightness !== "number" || isNaN(brightness)) { + console.warn( + "Type error: state-badge expected number, but type of " + + newVal.entity_id + + ".attributes.brightness is " + + typeof brightness + ); + } else { + // lowest brighntess will be around 50% (that's pretty dark) + iconStyle.filter = `brightness(${(brightness + 245) / 5}%)`; + } } } Object.assign(this.$.icon.style, iconStyle);