Complain and ignore instead of fixing

This commit is contained in:
Thomas Lovén 2018-10-19 12:07:33 +02:00
parent 1eb4ac7f34
commit bdc2b31202

View File

@ -88,8 +88,17 @@ class StateBadge extends PolymerElement {
} }
if (newVal.attributes.brightness) { if (newVal.attributes.brightness) {
const brightness = newVal.attributes.brightness; const brightness = newVal.attributes.brightness;
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) // lowest brighntess will be around 50% (that's pretty dark)
iconStyle.filter = `brightness(${(parseInt(brightness) + 245) / 5}%)`; iconStyle.filter = `brightness(${(brightness + 245) / 5}%)`;
}
} }
} }
Object.assign(this.$.icon.style, iconStyle); Object.assign(this.$.icon.style, iconStyle);