diff --git a/gallery/src/demos/demo-hui-picture-elements-card.ts b/gallery/src/demos/demo-hui-picture-elements-card.ts index aa991d7706..8c01770306 100644 --- a/gallery/src/demos/demo-hui-picture-elements-card.ts +++ b/gallery/src/demos/demo-hui-picture-elements-card.ts @@ -76,6 +76,55 @@ const CONFIGS = [ left: 35% `, }, + { + heading: "Card with header", + config: ` +- type: picture-elements + image: /images/floorplan.png + title: My House + elements: + - type: service-button + title: Lights Off + style: + top: 97% + left: 90% + padding: 0px + service: light.turn_off + service_data: + entity_id: group.all_lights + - type: icon + icon: mdi:cctv + entity: camera.demo_camera + style: + top: 12% + left: 6% + transform: rotate(-60deg) scaleX(-1) + --iron-icon-height: 30px + --iron-icon-width: 30px + --iron-icon-stroke-color: black + --iron-icon-fill-color: rgba(50, 50, 50, .75) + - type: image + entity: light.bed_light + tap_action: + action: toggle + image: /images/light_bulb_off.png + state_image: + 'on': /images/light_bulb_on.png + state_filter: + 'on': brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold) + 'off': brightness(80%) saturate(0.8) + style: + top: 35% + left: 65% + width: 7% + padding: 50px 50px 100px 50px + - type: state-icon + entity: binary_sensor.movement_backyard + style: + top: 8% + left: 35% + `, + }, ]; class DemoPicElements extends PolymerElement { diff --git a/setup.py b/setup.py index 592d744e5b..0323a19da7 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20181211.0", + version="20181211.1", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors", diff --git a/src/cards/ha-plant-card.js b/src/cards/ha-plant-card.js index f1a4fcbbdd..8334bf39cd 100644 --- a/src/cards/ha-plant-card.js +++ b/src/cards/ha-plant-card.js @@ -119,7 +119,7 @@ class HaPlantCard extends EventsMixin(PolymerElement) { } computeTitle(stateObj) { - return this.config.name || computeStateName(stateObj); + return (this.config && this.config.name) || computeStateName(stateObj); } computeAttributes(data) { diff --git a/src/cards/ha-weather-card.js b/src/cards/ha-weather-card.js index ef9e086c02..ce9ac0152d 100644 --- a/src/cards/ha-weather-card.js +++ b/src/cards/ha-weather-card.js @@ -39,6 +39,7 @@ class HaWeatherCard extends LocalizeMixin(EventsMixin(PolymerElement)) { opacity: var(--dark-primary-opacity); padding: 24px 16px 16px; display: flex; + align-items: baseline; } .name { @@ -195,6 +196,7 @@ class HaWeatherCard extends LocalizeMixin(EventsMixin(PolymerElement)) { static get properties() { return { hass: Object, + config: Object, stateObj: Object, forecast: { type: Array, @@ -274,7 +276,7 @@ class HaWeatherCard extends LocalizeMixin(EventsMixin(PolymerElement)) { } computeName(stateObj) { - return this.config.name || computeStateName(stateObj); + return (this.config && this.config.name) || computeStateName(stateObj); } showWeatherIcon(condition) { diff --git a/src/common/util/parse-aspect-ratio.ts b/src/common/util/parse-aspect-ratio.ts index cd80d4b90d..8fb1dee0a2 100644 --- a/src/common/util/parse-aspect-ratio.ts +++ b/src/common/util/parse-aspect-ratio.ts @@ -1,24 +1,30 @@ -export default function parseAspectRatio(input) { - // Handle 16x9, 16:9, 1.78x1, 1.78:1, 1.78 - // Ignore everything else - function parseOrThrow(num) { - const parsed = parseFloat(num); - if (isNaN(parsed)) { - throw new Error(`${num} is not a number`); - } - return parsed; +// Handle 16x9, 16:9, 1.78x1, 1.78:1, 1.78 +// Ignore everything else +const parseOrThrow = (num) => { + const parsed = parseFloat(num); + if (isNaN(parsed)) { + throw new Error(`${num} is not a number`); + } + return parsed; +}; + +export default function parseAspectRatio(input: string) { + if (!input) { + return null; } try { - if (input) { - const arr = input.replace(":", "x").split("x"); - if (arr.length === 0) { - return null; - } - - return arr.length === 1 - ? { w: parseOrThrow(arr[0]), h: 1 } - : { w: parseOrThrow(arr[0]), h: parseOrThrow(arr[1]) }; + if (input.endsWith("%")) { + return { w: 100, h: parseOrThrow(input.substr(0, input.length - 1)) }; } + + const arr = input.replace(":", "x").split("x"); + if (arr.length === 0) { + return null; + } + + return arr.length === 1 + ? { w: parseOrThrow(arr[0]), h: 1 } + : { w: parseOrThrow(arr[0]), h: parseOrThrow(arr[1]) }; } catch (err) { // Ignore the error } diff --git a/src/layouts/app/connection-mixin.js b/src/layouts/app/connection-mixin.js index 222d1b4ea2..6a763ffcde 100644 --- a/src/layouts/app/connection-mixin.js +++ b/src/layouts/app/connection-mixin.js @@ -56,6 +56,10 @@ export default (superClass) => dockedSidebar: false, moreInfoEntityId: null, callService: async (domain, service, serviceData = {}) => { + if (__DEV__) { + // eslint-disable-next-line + console.log("Calling service", domain, service, serviceData); + } try { await callService(conn, domain, service, serviceData); @@ -91,6 +95,15 @@ export default (superClass) => } this.fire("hass-notification", { message }); } catch (err) { + if (__DEV__) { + // eslint-disable-next-line + console.error( + "Error calling service", + domain, + service, + serviceData + ); + } const message = this.localize( "ui.notification_toast.service_call_failed", "service", @@ -106,21 +119,25 @@ export default (superClass) => fetchWithAuth(auth, `${auth.data.hassUrl}${path}`, init), // For messages that do not get a response sendWS: (msg) => { - // eslint-disable-next-line - if (__DEV__) console.log("Sending", msg); + if (__DEV__) { + // eslint-disable-next-line + console.log("Sending", msg); + } conn.sendMessage(msg); }, // For messages that expect a response callWS: (msg) => { - /* eslint-disable no-console */ - if (__DEV__) console.log("Sending", msg); + if (__DEV__) { + /* eslint-disable no-console */ + console.log("Sending", msg); + } const resp = conn.sendMessagePromise(msg); if (__DEV__) { resp.then( (result) => console.log("Received", result), - (err) => console.log("Error", err) + (err) => console.error("Error", err) ); } return resp; diff --git a/src/panels/config/cloud/cloud-exposed-entities.ts b/src/panels/config/cloud/cloud-exposed-entities.ts index e9d6438a2a..fd47f759b0 100644 --- a/src/panels/config/cloud/cloud-exposed-entities.ts +++ b/src/panels/config/cloud/cloud-exposed-entities.ts @@ -70,6 +70,7 @@ export class CloudExposedEntities extends LitElement { } protected updated(changedProperties: PropertyValues) { + super.updated(changedProperties); if ( changedProperties.has("filter") && changedProperties.get("filter") !== this.filter diff --git a/src/panels/config/cloud/cloud-webhooks.ts b/src/panels/config/cloud/cloud-webhooks.ts index db0d3a1dad..e89b6123a9 100644 --- a/src/panels/config/cloud/cloud-webhooks.ts +++ b/src/panels/config/cloud/cloud-webhooks.ts @@ -79,6 +79,7 @@ export class CloudWebhooks extends LitElement { } protected updated(changedProps: PropertyValues) { + super.updated(changedProps); if (changedProps.has("cloudStatus") && this.cloudStatus) { this._cloudHooks = this.cloudStatus.prefs.cloudhooks || {}; } diff --git a/src/panels/lovelace/cards/hui-entities-card.ts b/src/panels/lovelace/cards/hui-entities-card.ts index 188c8a15ae..1462183742 100644 --- a/src/panels/lovelace/cards/hui-entities-card.ts +++ b/src/panels/lovelace/cards/hui-entities-card.ts @@ -88,7 +88,8 @@ class HuiEntitiesCard extends hassLocalizeLitMixin(LitElement) this._configEntities = entities; } - protected updated(_changedProperties: PropertyValues): void { + protected updated(changedProperties: PropertyValues): void { + super.updated(changedProperties); if (this._hass && this._config) { applyThemesOnElement(this, this._hass.themes, this._config.theme); } diff --git a/src/panels/lovelace/cards/hui-entity-button-card.ts b/src/panels/lovelace/cards/hui-entity-button-card.ts index fbb074b0b4..d2b208ae40 100644 --- a/src/panels/lovelace/cards/hui-entity-button-card.ts +++ b/src/panels/lovelace/cards/hui-entity-button-card.ts @@ -116,6 +116,7 @@ class HuiEntityButtonCard extends hassLocalizeLitMixin(LitElement) } protected updated(changedProps: PropertyValues): void { + super.updated(changedProps); if (!this._config || !this.hass) { return; } diff --git a/src/panels/lovelace/cards/hui-gauge-card.ts b/src/panels/lovelace/cards/hui-gauge-card.ts index 65508b542e..3872d6ca12 100644 --- a/src/panels/lovelace/cards/hui-gauge-card.ts +++ b/src/panels/lovelace/cards/hui-gauge-card.ts @@ -110,11 +110,8 @@ class HuiGaugeCard extends LitElement implements LovelaceCard { } protected updated(changedProps: PropertyValues): void { - if ( - !this._config || - !this.hass || - !this.shadowRoot!.getElementById("gauge") - ) { + super.updated(changedProps); + if (!this._config || !this.hass) { return; } const stateObj = this.hass.states[this._config.entity]; diff --git a/src/panels/lovelace/cards/hui-glance-card.ts b/src/panels/lovelace/cards/hui-glance-card.ts index ff74e0dc0f..537bc405e2 100644 --- a/src/panels/lovelace/cards/hui-glance-card.ts +++ b/src/panels/lovelace/cards/hui-glance-card.ts @@ -135,6 +135,7 @@ export class HuiGlanceCard extends hassLocalizeLitMixin(LitElement) } protected updated(changedProperties: PropertyValues): void { + super.updated(changedProperties); if (!this._config || !this.hass) { return; } diff --git a/src/panels/lovelace/cards/hui-light-card.ts b/src/panels/lovelace/cards/hui-light-card.ts index 4dbdbc40c1..dc0ecad1e4 100644 --- a/src/panels/lovelace/cards/hui-light-card.ts +++ b/src/panels/lovelace/cards/hui-light-card.ts @@ -36,6 +36,7 @@ const lightConfig = { lineCap: "round", handleSize: "+12", showTooltip: false, + animation: false, }; interface Config extends LovelaceCardConfig { @@ -154,6 +155,7 @@ export class HuiLightCard extends hassLocalizeLitMixin(LitElement) } protected updated(changedProps: PropertyValues): void { + super.updated(changedProps); if (!this._config || !this.hass || !this._jQuery) { return; } diff --git a/src/panels/lovelace/cards/hui-picture-elements-card.ts b/src/panels/lovelace/cards/hui-picture-elements-card.ts index 072215f318..56a1de194d 100644 --- a/src/panels/lovelace/cards/hui-picture-elements-card.ts +++ b/src/panels/lovelace/cards/hui-picture-elements-card.ts @@ -63,15 +63,15 @@ class HuiPictureElementsCard extends LitElement implements LovelaceCard { return html` ${this.renderStyle()} -
+ ${ this._config.elements.map((elementConfig: LovelaceElementConfig) => this._createHuiElement(elementConfig) @@ -85,9 +85,9 @@ class HuiPictureElementsCard extends LitElement implements LovelaceCard { private renderStyle(): TemplateResult { return html`