From c53ec6e12dabc695158c009a63813daf62666ddd Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Sat, 21 Nov 2020 14:08:43 +0100 Subject: [PATCH] Ensure more consistent lovelace config errors (#7755) --- .../badges/hui-entity-filter-badge.ts | 6 +++--- .../lovelace/cards/hui-alarm-panel-card.ts | 2 +- src/panels/lovelace/cards/hui-button-card.ts | 5 ++++- .../lovelace/cards/hui-calendar-card.ts | 2 +- .../lovelace/cards/hui-conditional-card.ts | 2 +- .../lovelace/cards/hui-entities-card.ts | 4 ++++ src/panels/lovelace/cards/hui-entity-card.ts | 5 ++++- .../lovelace/cards/hui-entity-filter-card.ts | 6 +++--- src/panels/lovelace/cards/hui-gauge-card.ts | 20 ++++++++++++++++--- .../lovelace/cards/hui-humidifier-card.ts | 2 +- src/panels/lovelace/cards/hui-light-card.ts | 2 +- src/panels/lovelace/cards/hui-logbook-card.ts | 4 ++++ src/panels/lovelace/cards/hui-map-card.ts | 4 ++-- .../lovelace/cards/hui-markdown-card.ts | 2 +- .../lovelace/cards/hui-media-control-card.ts | 2 +- src/panels/lovelace/cards/hui-picture-card.ts | 2 +- .../cards/hui-picture-elements-card.ts | 6 +++--- .../lovelace/cards/hui-picture-entity-card.ts | 4 ++-- .../lovelace/cards/hui-picture-glance-card.ts | 2 +- .../lovelace/cards/hui-plant-status-card.ts | 2 +- src/panels/lovelace/cards/hui-sensor-card.ts | 2 +- src/panels/lovelace/cards/hui-stack-card.ts | 2 +- .../lovelace/cards/hui-thermostat-card.ts | 2 +- .../cards/hui-weather-forecast-card.ts | 6 +++--- .../components/hui-conditional-base.ts | 6 +++--- src/panels/lovelace/components/hui-warning.ts | 2 +- .../create-element/create-element-base.ts | 4 ++-- .../config-elements/hui-button-card-editor.ts | 2 +- .../config-elements/hui-entity-card-editor.ts | 2 +- .../hui-picture-glance-card-editor.ts | 2 +- .../elements/hui-conditional-element.ts | 2 +- .../lovelace/elements/hui-icon-element.ts | 2 +- .../lovelace/elements/hui-image-element.ts | 2 +- .../elements/hui-service-button-element.ts | 8 +++----- .../elements/hui-state-badge-element.ts | 2 +- .../elements/hui-state-icon-element.ts | 2 +- .../elements/hui-state-label-element.ts | 2 +- .../entity-rows/hui-climate-entity-row.ts | 2 +- .../entity-rows/hui-cover-entity-row.ts | 2 +- .../entity-rows/hui-group-entity-row.ts | 2 +- .../entity-rows/hui-humidifier-entity-row.ts | 2 +- .../hui-input-datetime-entity-row.ts | 2 +- .../hui-input-number-entity-row.ts | 2 +- .../hui-input-select-entity-row.ts | 2 +- .../entity-rows/hui-input-text-entity-row.ts | 2 +- .../entity-rows/hui-lock-entity-row.ts | 2 +- .../hui-media-player-entity-row.ts | 2 +- .../entity-rows/hui-scene-entity-row.ts | 2 +- .../entity-rows/hui-script-entity-row.ts | 2 +- .../entity-rows/hui-sensor-entity-row.ts | 2 +- .../entity-rows/hui-text-entity-row.ts | 2 +- .../entity-rows/hui-timer-entity-row.ts | 2 +- .../entity-rows/hui-toggle-entity-row.ts | 2 +- .../entity-rows/hui-weather-entity-row.ts | 2 +- .../header-footer/hui-graph-header-footer.ts | 4 +--- .../hui-picture-header-footer.ts | 2 +- .../special-rows/hui-attribute-row.ts | 6 +++--- .../lovelace/special-rows/hui-button-row.ts | 4 ++-- .../special-rows/hui-call-service-row.ts | 6 +++--- .../lovelace/special-rows/hui-cast-row.ts | 2 +- .../special-rows/hui-conditional-row.ts | 2 +- .../lovelace/special-rows/hui-section-row.ts | 2 +- .../lovelace/special-rows/hui-text-row.ts | 2 +- .../lovelace/special-rows/hui-weblink-row.ts | 2 +- src/translations/en.json | 11 +++++----- 65 files changed, 118 insertions(+), 93 deletions(-) diff --git a/src/panels/lovelace/badges/hui-entity-filter-badge.ts b/src/panels/lovelace/badges/hui-entity-filter-badge.ts index fb7db3d95d..d1dec26920 100644 --- a/src/panels/lovelace/badges/hui-entity-filter-badge.ts +++ b/src/panels/lovelace/badges/hui-entity-filter-badge.ts @@ -24,8 +24,8 @@ class EntityFilterBadge extends UpdatingElement implements LovelaceBadge { private _oldEntities?: EntityFilterEntityConfig[]; public setConfig(config: EntityFilterBadgeConfig): void { - if (!config.entities || !Array.isArray(config.entities)) { - throw new Error("entities must be specified."); + if (!config.entities.length || !Array.isArray(config.entities)) { + throw new Error("Entities must be specified"); } if ( @@ -37,7 +37,7 @@ class EntityFilterBadge extends UpdatingElement implements LovelaceBadge { Array.isArray(entity.state_filter) ) ) { - throw new Error("Incorrect filter config."); + throw new Error("Incorrect filter config"); } while (this.lastChild) { diff --git a/src/panels/lovelace/cards/hui-alarm-panel-card.ts b/src/panels/lovelace/cards/hui-alarm-panel-card.ts index 634941cfcf..a55baef9d8 100644 --- a/src/panels/lovelace/cards/hui-alarm-panel-card.ts +++ b/src/panels/lovelace/cards/hui-alarm-panel-card.ts @@ -94,7 +94,7 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard { !config.entity || config.entity.split(".")[0] !== "alarm_control_panel" ) { - throw new Error("Invalid card configuration"); + throw new Error("Invalid configuration"); } const defaults = { diff --git a/src/panels/lovelace/cards/hui-button-card.ts b/src/panels/lovelace/cards/hui-button-card.ts index c7fd8ba8ab..1f00582d94 100644 --- a/src/panels/lovelace/cards/hui-button-card.ts +++ b/src/panels/lovelace/cards/hui-button-card.ts @@ -85,8 +85,11 @@ export class HuiButtonCard extends LitElement implements LovelaceCard { } public setConfig(config: ButtonCardConfig): void { + if (!config.entity) { + throw new Error("Entity must be specified"); + } if (config.entity && !isValidEntityId(config.entity)) { - throw new Error("Invalid Entity"); + throw new Error("Invalid entity"); } this._config = { diff --git a/src/panels/lovelace/cards/hui-calendar-card.ts b/src/panels/lovelace/cards/hui-calendar-card.ts index 1e4fbd44d9..b35e7a10aa 100644 --- a/src/panels/lovelace/cards/hui-calendar-card.ts +++ b/src/panels/lovelace/cards/hui-calendar-card.ts @@ -83,7 +83,7 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard { public setConfig(config: CalendarCardConfig): void { if (!config.entities?.length) { - throw new Error("Entities must be defined"); + throw new Error("Entities must be specified"); } if (!Array.isArray(config.entities)) { diff --git a/src/panels/lovelace/cards/hui-conditional-card.ts b/src/panels/lovelace/cards/hui-conditional-card.ts index e9cd46a823..2598bcc110 100644 --- a/src/panels/lovelace/cards/hui-conditional-card.ts +++ b/src/panels/lovelace/cards/hui-conditional-card.ts @@ -28,7 +28,7 @@ class HuiConditionalCard extends HuiConditionalBase implements LovelaceCard { this.validateConfig(config); if (!config.card) { - throw new Error("No card configured."); + throw new Error("No card configured"); } this._element = this._createCardElement(config.card); diff --git a/src/panels/lovelace/cards/hui-entities-card.ts b/src/panels/lovelace/cards/hui-entities-card.ts index 7165b3b718..2ab7540c92 100644 --- a/src/panels/lovelace/cards/hui-entities-card.ts +++ b/src/panels/lovelace/cards/hui-entities-card.ts @@ -111,6 +111,10 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard { } public setConfig(config: EntitiesCardConfig): void { + if (!config || !config.entities.length) { + throw new Error("Entities must be specified"); + } + const entities = processConfigEntities(config.entities); this._config = config; diff --git a/src/panels/lovelace/cards/hui-entity-card.ts b/src/panels/lovelace/cards/hui-entity-card.ts index 7a4b2348bb..b6417f4193 100644 --- a/src/panels/lovelace/cards/hui-entity-card.ts +++ b/src/panels/lovelace/cards/hui-entity-card.ts @@ -68,8 +68,11 @@ export class HuiEntityCard extends LitElement implements LovelaceCard { private _footerElement?: HuiErrorCard | LovelaceHeaderFooter; public setConfig(config: EntityCardConfig): void { + if (!config.entity) { + throw new Error("Entity must be specified"); + } if (config.entity && !isValidEntityId(config.entity)) { - throw new Error("Invalid Entity"); + throw new Error("Invalid entity"); } this._config = config; diff --git a/src/panels/lovelace/cards/hui-entity-filter-card.ts b/src/panels/lovelace/cards/hui-entity-filter-card.ts index ecb8f211f6..00f6d120e8 100644 --- a/src/panels/lovelace/cards/hui-entity-filter-card.ts +++ b/src/panels/lovelace/cards/hui-entity-filter-card.ts @@ -36,8 +36,8 @@ class EntityFilterCard extends UpdatingElement implements LovelaceCard { } public setConfig(config: EntityFilterCardConfig): void { - if (!config.entities || !Array.isArray(config.entities)) { - throw new Error("entities must be specified."); + if (!config.entities.length || !Array.isArray(config.entities)) { + throw new Error("Entities must be specified"); } if ( @@ -49,7 +49,7 @@ class EntityFilterCard extends UpdatingElement implements LovelaceCard { Array.isArray(entity.state_filter) ) ) { - throw new Error("Incorrect filter config."); + throw new Error("Incorrect filter config"); } this._configEntities = processConfigEntities(config.entities); diff --git a/src/panels/lovelace/cards/hui-gauge-card.ts b/src/panels/lovelace/cards/hui-gauge-card.ts index c6ce2aa379..b3c699c6f4 100644 --- a/src/panels/lovelace/cards/hui-gauge-card.ts +++ b/src/panels/lovelace/cards/hui-gauge-card.ts @@ -18,6 +18,7 @@ import { isValidEntityId } from "../../../common/entity/valid_entity_id"; import "../../../components/ha-card"; import "../../../components/ha-gauge"; import type { HomeAssistant } from "../../../types"; +import { UNAVAILABLE } from "../../../data/entity"; import { findEntities } from "../common/find-entites"; import { hasConfigOrEntityChanged } from "../common/has-changed"; import { createEntityNotFoundWarning } from "../components/hui-warning"; @@ -72,12 +73,13 @@ class HuiGaugeCard extends LitElement implements LovelaceCard { } public setConfig(config: GaugeCardConfig): void { - if (!config || !config.entity) { - throw new Error("Invalid card configuration"); + if (!config.entity) { + throw new Error("Entity must be specified"); } if (!isValidEntityId(config.entity)) { - throw new Error("Invalid Entity"); + throw new Error("Invalid entity"); } + this._config = { min: 0, max: 100, ...config }; } @@ -98,6 +100,18 @@ class HuiGaugeCard extends LitElement implements LovelaceCard { const state = Number(stateObj.state); + if (stateObj.state === UNAVAILABLE) { + return html` + ${this.hass.localize( + "ui.panel.lovelace.warning.entity_unavailable", + "entity", + this._config.entity + )} + `; + } + if (isNaN(state)) { return html` (config.entities); this._config = { diff --git a/src/panels/lovelace/cards/hui-map-card.ts b/src/panels/lovelace/cards/hui-map-card.ts index 4d19b18848..e85e61ce75 100644 --- a/src/panels/lovelace/cards/hui-map-card.ts +++ b/src/panels/lovelace/cards/hui-map-card.ts @@ -137,9 +137,9 @@ class HuiMapCard extends LitElement implements LovelaceCard { throw new Error("Error in card configuration."); } - if (!config.entities && !config.geo_location_sources) { + if (!config.entities?.length && !config.geo_location_sources) { throw new Error( - "Either entities or geo_location_sources must be defined" + "Either entities or geo_location_sources must be specified" ); } if (config.entities && !Array.isArray(config.entities)) { diff --git a/src/panels/lovelace/cards/hui-markdown-card.ts b/src/panels/lovelace/cards/hui-markdown-card.ts index 3c7a361909..52d340ae65 100644 --- a/src/panels/lovelace/cards/hui-markdown-card.ts +++ b/src/panels/lovelace/cards/hui-markdown-card.ts @@ -58,7 +58,7 @@ export class HuiMarkdownCard extends LitElement implements LovelaceCard { public setConfig(config: MarkdownCardConfig): void { if (!config.content) { - throw new Error("Invalid Configuration: Content Required"); + throw new Error("Content required"); } if (this._config?.content !== config.content) { diff --git a/src/panels/lovelace/cards/hui-media-control-card.ts b/src/panels/lovelace/cards/hui-media-control-card.ts index 9ff35c43f6..f27727ffed 100644 --- a/src/panels/lovelace/cards/hui-media-control-card.ts +++ b/src/panels/lovelace/cards/hui-media-control-card.ts @@ -213,7 +213,7 @@ export class HuiMediaControlCard extends LitElement implements LovelaceCard { public setConfig(config: MediaControlCardConfig): void { if (!config.entity || config.entity.split(".")[0] !== "media_player") { - throw new Error("Specify an entity from within the media_player domain."); + throw new Error("Specify an entity from within the media_player domain"); } this._config = config; diff --git a/src/panels/lovelace/cards/hui-picture-card.ts b/src/panels/lovelace/cards/hui-picture-card.ts index a165d0b688..9f5ce5e49d 100644 --- a/src/panels/lovelace/cards/hui-picture-card.ts +++ b/src/panels/lovelace/cards/hui-picture-card.ts @@ -48,7 +48,7 @@ export class HuiPictureCard extends LitElement implements LovelaceCard { public setConfig(config: PictureCardConfig): void { if (!config || !config.image) { - throw new Error("Invalid Configuration: 'image' required"); + throw new Error("Image required"); } this._config = config; diff --git a/src/panels/lovelace/cards/hui-picture-elements-card.ts b/src/panels/lovelace/cards/hui-picture-elements-card.ts index dd01e10294..51c68971ef 100644 --- a/src/panels/lovelace/cards/hui-picture-elements-card.ts +++ b/src/panels/lovelace/cards/hui-picture-elements-card.ts @@ -62,14 +62,14 @@ class HuiPictureElementsCard extends LitElement implements LovelaceCard { public setConfig(config: PictureElementsCardConfig): void { if (!config) { - throw new Error("Invalid Configuration"); + throw new Error("Invalid configuration"); } else if ( !(config.image || config.camera_image || config.state_image) || (config.state_image && !config.entity) ) { - throw new Error("Invalid Configuration: image required"); + throw new Error("Image required"); } else if (!Array.isArray(config.elements)) { - throw new Error("Invalid Configuration: elements required"); + throw new Error("Elements required"); } this._config = config; diff --git a/src/panels/lovelace/cards/hui-picture-entity-card.ts b/src/panels/lovelace/cards/hui-picture-entity-card.ts index d20181536f..674fbe6c94 100644 --- a/src/panels/lovelace/cards/hui-picture-entity-card.ts +++ b/src/panels/lovelace/cards/hui-picture-entity-card.ts @@ -69,7 +69,7 @@ class HuiPictureEntityCard extends LitElement implements LovelaceCard { public setConfig(config: PictureEntityCardConfig): void { if (!config || !config.entity) { - throw new Error("Invalid Configuration: 'entity' required"); + throw new Error("Entity must be specified"); } if ( @@ -78,7 +78,7 @@ class HuiPictureEntityCard extends LitElement implements LovelaceCard { !config.state_image && !config.camera_image ) { - throw new Error("No image source configured."); + throw new Error("No image source configured"); } this._config = { show_name: true, show_state: true, ...config }; diff --git a/src/panels/lovelace/cards/hui-picture-glance-card.ts b/src/panels/lovelace/cards/hui-picture-glance-card.ts index b5a6ed9e1f..5cbb25c781 100644 --- a/src/panels/lovelace/cards/hui-picture-glance-card.ts +++ b/src/panels/lovelace/cards/hui-picture-glance-card.ts @@ -86,7 +86,7 @@ class HuiPictureGlanceCard extends LitElement implements LovelaceCard { !(config.image || config.camera_image || config.state_image) || (config.state_image && !config.entity) ) { - throw new Error("Invalid card configuration"); + throw new Error("Invalid configuration"); } const entities = processConfigEntities(config.entities); diff --git a/src/panels/lovelace/cards/hui-plant-status-card.ts b/src/panels/lovelace/cards/hui-plant-status-card.ts index d263c26b80..93278dcfd4 100644 --- a/src/panels/lovelace/cards/hui-plant-status-card.ts +++ b/src/panels/lovelace/cards/hui-plant-status-card.ts @@ -68,7 +68,7 @@ class HuiPlantStatusCard extends LitElement implements LovelaceCard { public setConfig(config: PlantStatusCardConfig): void { if (!config.entity || config.entity.split(".")[0] !== "plant") { - throw new Error("Specify an entity from within the plant domain."); + throw new Error("Specify an entity from within the plant domain"); } this._config = config; diff --git a/src/panels/lovelace/cards/hui-sensor-card.ts b/src/panels/lovelace/cards/hui-sensor-card.ts index f708e6bdac..63cb353c20 100644 --- a/src/panels/lovelace/cards/hui-sensor-card.ts +++ b/src/panels/lovelace/cards/hui-sensor-card.ts @@ -44,7 +44,7 @@ class HuiSensorCard extends HuiEntityCard { public setConfig(config: SensorCardConfig): void { if (!config.entity || config.entity.split(".")[0] !== "sensor") { - throw new Error("Specify an entity from within the sensor domain."); + throw new Error("Specify an entity from within the sensor domain"); } const { graph, detail, hours_to_show, ...cardConfig } = config; diff --git a/src/panels/lovelace/cards/hui-stack-card.ts b/src/panels/lovelace/cards/hui-stack-card.ts index aaa73530b4..a2824568db 100644 --- a/src/panels/lovelace/cards/hui-stack-card.ts +++ b/src/panels/lovelace/cards/hui-stack-card.ts @@ -42,7 +42,7 @@ export abstract class HuiStackCard public setConfig(config: T): void { if (!config || !config.cards || !Array.isArray(config.cards)) { - throw new Error("Card config incorrect"); + throw new Error("Invalid configuration"); } this._config = config; this._cards = config.cards.map((card) => { diff --git a/src/panels/lovelace/cards/hui-thermostat-card.ts b/src/panels/lovelace/cards/hui-thermostat-card.ts index 19e1ca9e95..d5b5c89481 100644 --- a/src/panels/lovelace/cards/hui-thermostat-card.ts +++ b/src/panels/lovelace/cards/hui-thermostat-card.ts @@ -87,7 +87,7 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard { public setConfig(config: ThermostatCardConfig): void { if (!config.entity || config.entity.split(".")[0] !== "climate") { - throw new Error("Specify an entity from within the climate domain."); + throw new Error("Specify an entity from within the climate domain"); } this._config = config; diff --git a/src/panels/lovelace/cards/hui-weather-forecast-card.ts b/src/panels/lovelace/cards/hui-weather-forecast-card.ts index 36c4bd8d1b..e0ac3c71bd 100644 --- a/src/panels/lovelace/cards/hui-weather-forecast-card.ts +++ b/src/panels/lovelace/cards/hui-weather-forecast-card.ts @@ -90,11 +90,11 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard { } public setConfig(config: WeatherForecastCardConfig): void { - if (!config || !config.entity) { - throw new Error("Invalid card configuration"); + if (!config.entity) { + throw new Error("Entity must be specified"); } if (!isValidEntityId(config.entity)) { - throw new Error("Invalid Entity"); + throw new Error("Invalid entity"); } this._config = config; diff --git a/src/panels/lovelace/components/hui-conditional-base.ts b/src/panels/lovelace/components/hui-conditional-base.ts index 867d157def..2089b144e8 100644 --- a/src/panels/lovelace/components/hui-conditional-base.ts +++ b/src/panels/lovelace/components/hui-conditional-base.ts @@ -27,15 +27,15 @@ export class HuiConditionalBase extends UpdatingElement { config: ConditionalCardConfig | ConditionalRowConfig ): void { if (!config.conditions) { - throw new Error("No conditions configured."); + throw new Error("No conditions configured"); } if (!Array.isArray(config.conditions)) { - throw new Error("Conditions should be in an array."); + throw new Error("Conditions need to be an array"); } if (!validateConditionalConfig(config.conditions)) { - throw new Error("Conditions are invalid."); + throw new Error("Conditions are invalid"); } if (this.lastChild) { diff --git a/src/panels/lovelace/components/hui-warning.ts b/src/panels/lovelace/components/hui-warning.ts index 2d58d9cbba..f91954c989 100644 --- a/src/panels/lovelace/components/hui-warning.ts +++ b/src/panels/lovelace/components/hui-warning.ts @@ -17,7 +17,7 @@ export const createEntityNotFoundWarning = ( ? hass.localize( "ui.panel.lovelace.warning.entity_not_found", "entity", - entityId + entityId || "[empty]" ) : hass.localize("ui.panel.lovelace.warning.starting"); }; diff --git a/src/panels/lovelace/create-element/create-element-base.ts b/src/panels/lovelace/create-element/create-element-base.ts index a3c700d28b..79e348f174 100644 --- a/src/panels/lovelace/create-element/create-element-base.ts +++ b/src/panels/lovelace/create-element/create-element-base.ts @@ -197,7 +197,7 @@ export const tryCreateLovelaceElement = < // If domain types is given, we can derive a type from "entity" (!domainTypes || !("entity" in config)) ) { - throw new Error("No card type configured."); + throw new Error("No card type configured"); } const customTag = config.type ? _getCustomTag(config.type) : undefined; @@ -219,7 +219,7 @@ export const tryCreateLovelaceElement = < } if (type === undefined) { - throw new Error("No type specified."); + throw new Error("No type specified"); } const tag = `hui-${type}-${tagSuffix}`; diff --git a/src/panels/lovelace/editor/config-elements/hui-button-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-button-card-editor.ts index 2b4ff6acfd..544f5af0f0 100644 --- a/src/panels/lovelace/editor/config-elements/hui-button-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-button-card-editor.ts @@ -115,7 +115,7 @@ export class HuiButtonCardEditor extends LitElement .label="${this.hass.localize( "ui.panel.lovelace.editor.card.generic.entity" )} (${this.hass.localize( - "ui.panel.lovelace.editor.card.config.optional" + "ui.panel.lovelace.editor.card.config.required" )})" .hass=${this.hass} .value=${this._entity} diff --git a/src/panels/lovelace/editor/config-elements/hui-entity-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-entity-card-editor.ts index f4d8f54921..1c1e0aeb0b 100644 --- a/src/panels/lovelace/editor/config-elements/hui-entity-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-entity-card-editor.ts @@ -81,7 +81,7 @@ export class HuiEntityCardEditor extends LitElement .label="${this.hass.localize( "ui.panel.lovelace.editor.card.generic.entity" )} (${this.hass.localize( - "ui.panel.lovelace.editor.card.config.optional" + "ui.panel.lovelace.editor.card.config.required" )})" .hass=${this.hass} .value=${this._entity} diff --git a/src/panels/lovelace/editor/config-elements/hui-picture-glance-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-picture-glance-card-editor.ts index fd68a51057..43d4816e03 100644 --- a/src/panels/lovelace/editor/config-elements/hui-picture-glance-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-picture-glance-card-editor.ts @@ -178,7 +178,7 @@ export class HuiPictureGlanceCardEditor extends LitElement 0) { diff --git a/src/panels/lovelace/elements/hui-icon-element.ts b/src/panels/lovelace/elements/hui-icon-element.ts index 4811f219ac..5c934ce593 100644 --- a/src/panels/lovelace/elements/hui-icon-element.ts +++ b/src/panels/lovelace/elements/hui-icon-element.ts @@ -25,7 +25,7 @@ export class HuiIconElement extends LitElement implements LovelaceElement { public setConfig(config: IconElementConfig): void { if (!config.icon) { - throw Error("Invalid Configuration: 'icon' required"); + throw Error("Icon required"); } this._config = { hold_action: { action: "more-info" }, ...config }; diff --git a/src/panels/lovelace/elements/hui-image-element.ts b/src/panels/lovelace/elements/hui-image-element.ts index 50e45c153a..ab4d328d71 100644 --- a/src/panels/lovelace/elements/hui-image-element.ts +++ b/src/panels/lovelace/elements/hui-image-element.ts @@ -26,7 +26,7 @@ export class HuiImageElement extends LitElement implements LovelaceElement { public setConfig(config: ImageElementConfig): void { if (!config) { - throw Error("Error in element configuration"); + throw Error("Invalid configuration"); } this._config = { hold_action: { action: "more-info" }, ...config }; diff --git a/src/panels/lovelace/elements/hui-service-button-element.ts b/src/panels/lovelace/elements/hui-service-button-element.ts index a9af59cf0e..016526f987 100644 --- a/src/panels/lovelace/elements/hui-service-button-element.ts +++ b/src/panels/lovelace/elements/hui-service-button-element.ts @@ -24,19 +24,17 @@ export class HuiServiceButtonElement extends LitElement public setConfig(config: ServiceButtonElementConfig): void { if (!config || !config.service) { - throw Error("Invalid Configuration: 'service' required"); + throw Error("Service required"); } [this._domain, this._service] = config.service.split(".", 2); if (!this._domain) { - throw Error("Invalid Configuration: 'service' does not have a domain"); + throw Error("Service does not have a service domain"); } if (!this._service) { - throw Error( - "Invalid Configuration: 'service' does not have a service name" - ); + throw Error("Service does not have a service name"); } this._config = config; diff --git a/src/panels/lovelace/elements/hui-state-badge-element.ts b/src/panels/lovelace/elements/hui-state-badge-element.ts index 1baa6b0d8d..33b279ed73 100644 --- a/src/panels/lovelace/elements/hui-state-badge-element.ts +++ b/src/panels/lovelace/elements/hui-state-badge-element.ts @@ -29,7 +29,7 @@ export class HuiStateBadgeElement extends LitElement public setConfig(config: StateBadgeElementConfig): void { if (!config.entity) { - throw Error("Invalid Configuration: 'entity' required"); + throw Error("Entity required"); } this._config = { hold_action: { action: "more-info" }, ...config }; diff --git a/src/panels/lovelace/elements/hui-state-icon-element.ts b/src/panels/lovelace/elements/hui-state-icon-element.ts index 84c8593ad0..7ec7fdcdf4 100644 --- a/src/panels/lovelace/elements/hui-state-icon-element.ts +++ b/src/panels/lovelace/elements/hui-state-icon-element.ts @@ -30,7 +30,7 @@ export class HuiStateIconElement extends LitElement implements LovelaceElement { public setConfig(config: StateIconElementConfig): void { if (!config.entity) { - throw Error("Invalid Configuration: 'entity' required"); + throw Error("Entity required"); } this._config = { diff --git a/src/panels/lovelace/elements/hui-state-label-element.ts b/src/panels/lovelace/elements/hui-state-label-element.ts index 7296f0dc64..5c16451496 100644 --- a/src/panels/lovelace/elements/hui-state-label-element.ts +++ b/src/panels/lovelace/elements/hui-state-label-element.ts @@ -30,7 +30,7 @@ class HuiStateLabelElement extends LitElement implements LovelaceElement { public setConfig(config: StateLabelElementConfig): void { if (!config.entity) { - throw Error("Invalid Configuration: 'entity' required"); + throw Error("Entity required"); } this._config = { hold_action: { action: "more-info" }, ...config }; diff --git a/src/panels/lovelace/entity-rows/hui-climate-entity-row.ts b/src/panels/lovelace/entity-rows/hui-climate-entity-row.ts index a229fa71f6..b66341bb9a 100644 --- a/src/panels/lovelace/entity-rows/hui-climate-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-climate-entity-row.ts @@ -24,7 +24,7 @@ class HuiClimateEntityRow extends LitElement implements LovelaceRow { public setConfig(config: EntityConfig): void { if (!config || !config.entity) { - throw new Error("Invalid Configuration: 'entity' required"); + throw new Error("Entity must be specified"); } this._config = config; diff --git a/src/panels/lovelace/entity-rows/hui-cover-entity-row.ts b/src/panels/lovelace/entity-rows/hui-cover-entity-row.ts index da8530541e..fb8cc22265 100644 --- a/src/panels/lovelace/entity-rows/hui-cover-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-cover-entity-row.ts @@ -26,7 +26,7 @@ class HuiCoverEntityRow extends LitElement implements LovelaceRow { public setConfig(config: EntityConfig): void { if (!config) { - throw new Error("Configuration error"); + throw new Error("Invalid configuration"); } this._config = config; } diff --git a/src/panels/lovelace/entity-rows/hui-group-entity-row.ts b/src/panels/lovelace/entity-rows/hui-group-entity-row.ts index fb414e312f..3b256f629d 100644 --- a/src/panels/lovelace/entity-rows/hui-group-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-group-entity-row.ts @@ -38,7 +38,7 @@ class HuiGroupEntityRow extends LitElement implements LovelaceRow { public setConfig(config: EntityConfig): void { if (!config) { - throw new Error("Configuration error"); + throw new Error("Invalid configuration"); } this._config = config; } diff --git a/src/panels/lovelace/entity-rows/hui-humidifier-entity-row.ts b/src/panels/lovelace/entity-rows/hui-humidifier-entity-row.ts index 58a8dc79ae..7a2e1a12b6 100644 --- a/src/panels/lovelace/entity-rows/hui-humidifier-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-humidifier-entity-row.ts @@ -21,7 +21,7 @@ class HuiHumidifierEntityRow extends LitElement implements LovelaceRow { public setConfig(config: EntityConfig): void { if (!config || !config.entity) { - throw new Error("Invalid Configuration: 'entity' required"); + throw new Error("Entity must be specified"); } this._config = config; diff --git a/src/panels/lovelace/entity-rows/hui-input-datetime-entity-row.ts b/src/panels/lovelace/entity-rows/hui-input-datetime-entity-row.ts index 3d3ab67e60..77f971e6c8 100644 --- a/src/panels/lovelace/entity-rows/hui-input-datetime-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-input-datetime-entity-row.ts @@ -27,7 +27,7 @@ class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow { public setConfig(config: EntityConfig): void { if (!config) { - throw new Error("Configuration error"); + throw new Error("Invalid configuration"); } this._config = config; } diff --git a/src/panels/lovelace/entity-rows/hui-input-number-entity-row.ts b/src/panels/lovelace/entity-rows/hui-input-number-entity-row.ts index 22a0c3d57f..051b32db71 100644 --- a/src/panels/lovelace/entity-rows/hui-input-number-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-input-number-entity-row.ts @@ -32,7 +32,7 @@ class HuiInputNumberEntityRow extends LitElement implements LovelaceRow { public setConfig(config: EntityConfig): void { if (!config) { - throw new Error("Configuration error"); + throw new Error("Invalid configuration"); } this._config = config; } diff --git a/src/panels/lovelace/entity-rows/hui-input-select-entity-row.ts b/src/panels/lovelace/entity-rows/hui-input-select-entity-row.ts index e7e19aa8ff..790467cdc1 100644 --- a/src/panels/lovelace/entity-rows/hui-input-select-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-input-select-entity-row.ts @@ -40,7 +40,7 @@ class HuiInputSelectEntityRow extends LitElement implements LovelaceRow { public setConfig(config: EntitiesCardEntityConfig): void { if (!config || !config.entity) { - throw new Error("Invalid Configuration: 'entity' required"); + throw new Error("Entity must be specified"); } this._config = config; diff --git a/src/panels/lovelace/entity-rows/hui-input-text-entity-row.ts b/src/panels/lovelace/entity-rows/hui-input-text-entity-row.ts index a503aa1c1f..02c18143d3 100644 --- a/src/panels/lovelace/entity-rows/hui-input-text-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-input-text-entity-row.ts @@ -24,7 +24,7 @@ class HuiInputTextEntityRow extends LitElement implements LovelaceRow { public setConfig(config: EntityConfig): void { if (!config) { - throw new Error("Configuration error"); + throw new Error("Invalid configuration"); } this._config = config; } diff --git a/src/panels/lovelace/entity-rows/hui-lock-entity-row.ts b/src/panels/lovelace/entity-rows/hui-lock-entity-row.ts index 1645638750..c8ae2e0b99 100644 --- a/src/panels/lovelace/entity-rows/hui-lock-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-lock-entity-row.ts @@ -25,7 +25,7 @@ class HuiLockEntityRow extends LitElement implements LovelaceRow { public setConfig(config: EntityConfig): void { if (!config) { - throw new Error("Configuration error"); + throw new Error("Invalid configuration"); } this._config = config; } diff --git a/src/panels/lovelace/entity-rows/hui-media-player-entity-row.ts b/src/panels/lovelace/entity-rows/hui-media-player-entity-row.ts index 654e4dd771..a8a25ca6b0 100644 --- a/src/panels/lovelace/entity-rows/hui-media-player-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-media-player-entity-row.ts @@ -51,7 +51,7 @@ class HuiMediaPlayerEntityRow extends LitElement implements LovelaceRow { public setConfig(config: EntityConfig): void { if (!config || !config.entity) { - throw new Error("Invalid Configuration: 'entity' required"); + throw new Error("Entity must be specified"); } this._config = config; diff --git a/src/panels/lovelace/entity-rows/hui-scene-entity-row.ts b/src/panels/lovelace/entity-rows/hui-scene-entity-row.ts index 5e1f778a49..50d0867d56 100644 --- a/src/panels/lovelace/entity-rows/hui-scene-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-scene-entity-row.ts @@ -27,7 +27,7 @@ class HuiSceneEntityRow extends LitElement implements LovelaceRow { public setConfig(config: ActionRowConfig): void { if (!config) { - throw new Error("Configuration error"); + throw new Error("Invalid configuration"); } this._config = config; } diff --git a/src/panels/lovelace/entity-rows/hui-script-entity-row.ts b/src/panels/lovelace/entity-rows/hui-script-entity-row.ts index 1bddffbdbd..ac2e0d3a13 100644 --- a/src/panels/lovelace/entity-rows/hui-script-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-script-entity-row.ts @@ -26,7 +26,7 @@ class HuiScriptEntityRow extends LitElement implements LovelaceRow { public setConfig(config: ActionRowConfig): void { if (!config) { - throw new Error("Configuration error"); + throw new Error("Invalid configuration"); } this._config = config; } diff --git a/src/panels/lovelace/entity-rows/hui-sensor-entity-row.ts b/src/panels/lovelace/entity-rows/hui-sensor-entity-row.ts index a29147145c..52c644788d 100644 --- a/src/panels/lovelace/entity-rows/hui-sensor-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-sensor-entity-row.ts @@ -36,7 +36,7 @@ class HuiSensorEntityRow extends LitElement implements LovelaceRow { public setConfig(config: SensorEntityConfig): void { if (!config) { - throw new Error("Configuration error"); + throw new Error("Invalid configuration"); } this._config = config; } diff --git a/src/panels/lovelace/entity-rows/hui-text-entity-row.ts b/src/panels/lovelace/entity-rows/hui-text-entity-row.ts index ece1924787..c00678990f 100644 --- a/src/panels/lovelace/entity-rows/hui-text-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-text-entity-row.ts @@ -32,7 +32,7 @@ class HuiTextEntityRow extends LitElement implements LovelaceRow { public setConfig(config: EntitiesCardEntityConfig): void { if (!config) { - throw new Error("Configuration error"); + throw new Error("Invalid configuration"); } this._config = config; } diff --git a/src/panels/lovelace/entity-rows/hui-timer-entity-row.ts b/src/panels/lovelace/entity-rows/hui-timer-entity-row.ts index b77225c28d..a8fc0f0b2a 100644 --- a/src/panels/lovelace/entity-rows/hui-timer-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-timer-entity-row.ts @@ -28,7 +28,7 @@ class HuiTimerEntityRow extends LitElement { public setConfig(config: EntityConfig): void { if (!config) { - throw new Error("Configuration error"); + throw new Error("Invalid configuration"); } this._config = config; } diff --git a/src/panels/lovelace/entity-rows/hui-toggle-entity-row.ts b/src/panels/lovelace/entity-rows/hui-toggle-entity-row.ts index 30e13cf265..685221f821 100644 --- a/src/panels/lovelace/entity-rows/hui-toggle-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-toggle-entity-row.ts @@ -24,7 +24,7 @@ class HuiToggleEntityRow extends LitElement implements LovelaceRow { public setConfig(config: EntityConfig): void { if (!config) { - throw new Error("Configuration error"); + throw new Error("Invalid configuration"); } this._config = config; } diff --git a/src/panels/lovelace/entity-rows/hui-weather-entity-row.ts b/src/panels/lovelace/entity-rows/hui-weather-entity-row.ts index 8570fc71a6..c33d3c2e3c 100644 --- a/src/panels/lovelace/entity-rows/hui-weather-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-weather-entity-row.ts @@ -44,7 +44,7 @@ class HuiWeatherEntityRow extends LitElement implements LovelaceRow { public setConfig(config: EntitiesCardEntityConfig): void { if (!config?.entity) { - throw new Error("Invalid Configuration: 'entity' required"); + throw new Error("Entity must be specified"); } this._config = config; diff --git a/src/panels/lovelace/header-footer/hui-graph-header-footer.ts b/src/panels/lovelace/header-footer/hui-graph-header-footer.ts index 9e9132c182..cf31ea8ab4 100644 --- a/src/panels/lovelace/header-footer/hui-graph-header-footer.ts +++ b/src/panels/lovelace/header-footer/hui-graph-header-footer.ts @@ -80,9 +80,7 @@ export class HuiGraphHeaderFooter extends LitElement public setConfig(config: GraphHeaderFooterConfig): void { if (!config?.entity || config.entity.split(".")[0] !== "sensor") { - throw new Error( - "Invalid Configuration: An entity from within the sensor domain required" - ); + throw new Error("Specify an entity from within the sensor domain"); } const cardConfig = { diff --git a/src/panels/lovelace/header-footer/hui-picture-header-footer.ts b/src/panels/lovelace/header-footer/hui-picture-header-footer.ts index dd762486ef..23b25e6470 100644 --- a/src/panels/lovelace/header-footer/hui-picture-header-footer.ts +++ b/src/panels/lovelace/header-footer/hui-picture-header-footer.ts @@ -41,7 +41,7 @@ export class HuiPictureHeaderFooter extends LitElement public setConfig(config: PictureHeaderFooterConfig): void { if (!config || !config.image) { - throw new Error("Invalid Configuration: 'image' required"); + throw new Error("Image required"); } this._config = config; diff --git a/src/panels/lovelace/special-rows/hui-attribute-row.ts b/src/panels/lovelace/special-rows/hui-attribute-row.ts index 1a6399fcc8..97a44d2867 100644 --- a/src/panels/lovelace/special-rows/hui-attribute-row.ts +++ b/src/panels/lovelace/special-rows/hui-attribute-row.ts @@ -23,13 +23,13 @@ class HuiAttributeRow extends LitElement implements LovelaceRow { public setConfig(config: AttributeRowConfig): void { if (!config) { - throw new Error("Configuration error"); + throw new Error("Invalid configuration"); } if (!config.entity) { - throw new Error("Entity not defined"); + throw new Error("Entity not specified"); } if (!config.attribute) { - throw new Error("Attribute not defined"); + throw new Error("Attribute not specified"); } this._config = config; } diff --git a/src/panels/lovelace/special-rows/hui-button-row.ts b/src/panels/lovelace/special-rows/hui-button-row.ts index 1a74621dd9..91e905c846 100644 --- a/src/panels/lovelace/special-rows/hui-button-row.ts +++ b/src/panels/lovelace/special-rows/hui-button-row.ts @@ -26,11 +26,11 @@ export class HuiButtonRow extends LitElement implements LovelaceRow { public setConfig(config: ButtonRowConfig): void { if (!config) { - throw new Error("Error in card configuration."); + throw new Error("Invalid configuration"); } if (!config.name) { - throw new Error("Error in card configuration. No name specified."); + throw new Error("No name specified"); } this._config = { diff --git a/src/panels/lovelace/special-rows/hui-call-service-row.ts b/src/panels/lovelace/special-rows/hui-call-service-row.ts index 80a682e70b..1bfed88f0f 100644 --- a/src/panels/lovelace/special-rows/hui-call-service-row.ts +++ b/src/panels/lovelace/special-rows/hui-call-service-row.ts @@ -8,15 +8,15 @@ export class HuiCallServiceRow extends HuiButtonRow { const callServiceConfig: CallServiceConfig = config; if (!callServiceConfig) { - throw new Error("Error in card configuration."); + throw new Error("Invalid configuration"); } if (!callServiceConfig.name) { - throw new Error("Error in card configuration. No name specified."); + throw new Error("No name specified"); } if (!callServiceConfig.service) { - throw new Error("Error in card configuration. No service specified."); + throw new Error("No service specified"); } super.setConfig({ diff --git a/src/panels/lovelace/special-rows/hui-cast-row.ts b/src/panels/lovelace/special-rows/hui-cast-row.ts index db4bb01788..22d6369b2d 100644 --- a/src/panels/lovelace/special-rows/hui-cast-row.ts +++ b/src/panels/lovelace/special-rows/hui-cast-row.ts @@ -32,7 +32,7 @@ class HuiCastRow extends LitElement implements LovelaceRow { public setConfig(config: CastConfig): void { if (!config || config.view === undefined || config.view === null) { - throw new Error("Invalid Configuration: 'view' required"); + throw new Error("View required"); } this._config = { diff --git a/src/panels/lovelace/special-rows/hui-conditional-row.ts b/src/panels/lovelace/special-rows/hui-conditional-row.ts index 06364cbef0..65b04afdb3 100644 --- a/src/panels/lovelace/special-rows/hui-conditional-row.ts +++ b/src/panels/lovelace/special-rows/hui-conditional-row.ts @@ -9,7 +9,7 @@ class HuiConditionalRow extends HuiConditionalBase implements LovelaceRow { this.validateConfig(config); if (!config.row) { - throw new Error("No row configured."); + throw new Error("No row configured"); } this._element = createRowElement(config.row) as LovelaceRow; diff --git a/src/panels/lovelace/special-rows/hui-section-row.ts b/src/panels/lovelace/special-rows/hui-section-row.ts index 3b94b40944..ce8a0e08ab 100644 --- a/src/panels/lovelace/special-rows/hui-section-row.ts +++ b/src/panels/lovelace/special-rows/hui-section-row.ts @@ -19,7 +19,7 @@ class HuiSectionRow extends LitElement implements LovelaceRow { public setConfig(config: SectionConfig): void { if (!config) { - throw new Error("Error in card configuration."); + throw new Error("Invalid configuration"); } this._config = config; diff --git a/src/panels/lovelace/special-rows/hui-text-row.ts b/src/panels/lovelace/special-rows/hui-text-row.ts index d2b0786a9d..7fb0b435eb 100644 --- a/src/panels/lovelace/special-rows/hui-text-row.ts +++ b/src/panels/lovelace/special-rows/hui-text-row.ts @@ -16,7 +16,7 @@ class HuiTextRow extends LitElement implements LovelaceRow { public setConfig(config: TextConfig): void { if (!config || !config.name || !config.text) { - throw new Error("Invalid Configuration: 'name' and 'text' required"); + throw new Error("Name and text required"); } this._config = config; diff --git a/src/panels/lovelace/special-rows/hui-weblink-row.ts b/src/panels/lovelace/special-rows/hui-weblink-row.ts index 1e278c0d37..e5502d006b 100644 --- a/src/panels/lovelace/special-rows/hui-weblink-row.ts +++ b/src/panels/lovelace/special-rows/hui-weblink-row.ts @@ -19,7 +19,7 @@ class HuiWeblinkRow extends LitElement implements LovelaceRow { public setConfig(config: WeblinkConfig): void { if (!config || !config.url) { - throw new Error("Invalid Configuration: 'url' required"); + throw new Error("URL required"); } this._config = { diff --git a/src/translations/en.json b/src/translations/en.json index c25e9614b2..da7ce90eea 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -65,7 +65,7 @@ "unknown": "Unk", "unavailable": "Unavai", "error": "Error", - "entity_not_found": "Entity Not Found" + "entity_not_found": "Entity not found" }, "alarm_control_panel": { "armed": "Armed", @@ -1959,8 +1959,8 @@ "hub": "Connected via", "firmware": "Firmware: {version}", "unnamed_entry": "Unnamed entry", - "device_unavailable": "device unavailable", - "entity_unavailable": "entity unavailable", + "device_unavailable": "Device unavailable", + "entity_unavailable": "Entity unavailable", "area": "In {area}", "no_area": "No Area" }, @@ -2721,7 +2721,8 @@ }, "picture-glance": { "name": "Picture Glance", - "description": "The Picture Glance card shows an image and corresponding entity states as an icon. The entities on the right side allow toggle actions, others show the more information dialog." + "description": "The Picture Glance card shows an image and corresponding entity states as an icon. The entities on the right side allow toggle actions, others show the more information dialog.", + "state_entity": "State Entity" }, "plant-status": { "name": "Plant Status", @@ -2795,7 +2796,7 @@ "attribute_not_found": "Attribute {attribute} not available in: {entity}", "entity_not_found": "Entity not available: {entity}", "entity_non_numeric": "Entity is non-numeric: {entity}", - "entity_unavailable": "{entity} is currently unavailable", + "entity_unavailable": "Entity is currently unavailable: {entity}", "starting": "Home Assistant is starting, not everything may be available yet" }, "changed_toast": {