Skip to content

Commit

Permalink
Added fallback entity icon
Browse files Browse the repository at this point in the history
  • Loading branch information
kalkih committed Nov 10, 2018
1 parent 5ad0083 commit 2a650cd
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions mini-graph-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { LitElement, html, svg } from 'https://unpkg.com/@polymer/lit-element@^0
import Graph from './mini-graph-lib.js';

const FONT_SIZE = 14;
const ICON = {
humidity: 'hass:water-percent',
illuminance: 'hass:brightness-5',
temperature: 'hass:thermometer',
battery: 'hass:battery'
};

class MiniGraphCard extends LitElement {
constructor() {
super();
this.conf = {};
this._icons = {
humidity: 'hass:water-percent',
illuminance: 'hass:brightness-5',
temperature: 'hass:thermometer',
battery: 'hass:battery'
};
}

createRenderRoot() {
Expand Down Expand Up @@ -151,7 +151,8 @@ class MiniGraphCard extends LitElement {
computeIcon(entity) {
return this.config.icon ||
entity.attributes.icon ||
this._icons[entity.attributes.device_class];
ICON[entity.attributes.device_class] ||
ICON.temperature;
}

computeUom(entity) {
Expand Down

0 comments on commit 2a650cd

Please sign in to comment.