Lovelace cleanups (#3427)

* Improvements

* Add types CAF

* Fix demo switching

* Do not set background color in hui-view
This commit is contained in:
Paulus Schoutsen
2019-07-26 11:06:16 -07:00
committed by GitHub
parent dae0ecce6a
commit 6abbe72e4d
30 changed files with 233 additions and 107 deletions

View File

@@ -199,3 +199,9 @@ class HaEntityPicker extends LitElement {
}
customElements.define("ha-entity-picker", HaEntityPicker);
declare global {
interface HTMLElementTagNameMap {
"ha-entity-picker": HaEntityPicker;
}
}

View File

@@ -15,8 +15,10 @@ import { HassEntity } from "home-assistant-js-websocket";
// Not duplicate, this is for typing.
// tslint:disable-next-line
import { HaIcon } from "../ha-icon";
import { HomeAssistant } from "../../types";
class StateBadge extends LitElement {
public hass?: HomeAssistant;
@property() public stateObj?: HassEntity;
@property() public overrideIcon?: string;
@query("ha-icon") private _icon!: HaIcon;
@@ -54,8 +56,11 @@ class StateBadge extends LitElement {
if (stateObj) {
// hide icon if we have entity picture
if (stateObj.attributes.entity_picture && !this.overrideIcon) {
hostStyle.backgroundImage =
"url(" + stateObj.attributes.entity_picture + ")";
let imageUrl = stateObj.attributes.entity_picture;
if (this.hass) {
imageUrl = this.hass.hassUrl(imageUrl);
}
hostStyle.backgroundImage = `url(${imageUrl})`;
iconStyle.display = "none";
} else {
if (stateObj.attributes.hs_color) {