+
+
diff --git a/src/components/entity/state-badge.js b/src/components/entity/state-badge.js
index 72c95575a4..4561cea563 100644
--- a/src/components/entity/state-badge.js
+++ b/src/components/entity/state-badge.js
@@ -16,6 +16,16 @@ export default new Polymer({
* Called when an attribute changes that influences the color of the icon.
*/
updateIconColor(newVal) {
+ // hide icon if we have entity picture
+ if (newVal.attributes.entity_picture) {
+ this.style.backgroundImage = `url(${newVal.attributes.entity_picture})`;
+ this.$.icon.style.display = 'none';
+ return;
+ }
+
+ this.style.backgroundImage = '';
+ this.$.icon.style.display = 'inline';
+
// 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' &&
diff --git a/src/components/ha-label-badge.html b/src/components/ha-label-badge.html
index 1811d3f4ef..c20d827af6 100644
--- a/src/components/ha-label-badge.html
+++ b/src/components/ha-label-badge.html
@@ -1,5 +1,4 @@
-
@@ -25,6 +24,7 @@
white-space: nowrap;
background-color: white;
+ background-size: cover;
transition: border .3s ease-in-out;
}
.label-badge .value {
@@ -74,17 +74,10 @@
-
-
-
- [[value]]
-
-
-
+
+ [[value]]
-
-
[[label]]
-
+
[[label]]
[[description]]
diff --git a/src/components/ha-label-badge.js b/src/components/ha-label-badge.js
index 8184121ebb..ead99ea720 100644
--- a/src/components/ha-label-badge.js
+++ b/src/components/ha-label-badge.js
@@ -1,19 +1,24 @@
import Polymer from '../polymer';
+// Beware: Polymer will not call computeHideIcon and computeHideValue if any of
+// the parameters are undefined. Set to null if not using.
export default new Polymer({
is: 'ha-label-badge',
properties: {
value: {
type: String,
+ value: null,
},
icon: {
type: String,
+ value: null,
},
label: {
type: String,
+ value: null,
},
description: {
@@ -22,11 +27,24 @@ export default new Polymer({
image: {
type: String,
- observe: 'imageChanged',
+ value: null,
+ observer: 'imageChanged',
},
},
computeClasses(value) {
return value && value.length > 4 ? 'value big' : 'value';
},
+
+ computeHideIcon(icon, value, image) {
+ return !icon || value || image;
+ },
+
+ computeHideValue(value, image) {
+ return !value || image;
+ },
+
+ imageChanged(newVal) {
+ this.$.badge.style.backgroundImage = newVal ? `url(${newVal})` : '';
+ },
});