Ensure more consistent lovelace config errors (#7755)

This commit is contained in:
Philip Allgaier 2020-11-21 14:08:43 +01:00 committed by GitHub
parent aad6492a6a
commit c53ec6e12d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
65 changed files with 118 additions and 93 deletions

View File

@ -24,8 +24,8 @@ class EntityFilterBadge extends UpdatingElement implements LovelaceBadge {
private _oldEntities?: EntityFilterEntityConfig[]; private _oldEntities?: EntityFilterEntityConfig[];
public setConfig(config: EntityFilterBadgeConfig): void { public setConfig(config: EntityFilterBadgeConfig): void {
if (!config.entities || !Array.isArray(config.entities)) { if (!config.entities.length || !Array.isArray(config.entities)) {
throw new Error("entities must be specified."); throw new Error("Entities must be specified");
} }
if ( if (
@ -37,7 +37,7 @@ class EntityFilterBadge extends UpdatingElement implements LovelaceBadge {
Array.isArray(entity.state_filter) Array.isArray(entity.state_filter)
) )
) { ) {
throw new Error("Incorrect filter config."); throw new Error("Incorrect filter config");
} }
while (this.lastChild) { while (this.lastChild) {

View File

@ -94,7 +94,7 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
!config.entity || !config.entity ||
config.entity.split(".")[0] !== "alarm_control_panel" config.entity.split(".")[0] !== "alarm_control_panel"
) { ) {
throw new Error("Invalid card configuration"); throw new Error("Invalid configuration");
} }
const defaults = { const defaults = {

View File

@ -85,8 +85,11 @@ export class HuiButtonCard extends LitElement implements LovelaceCard {
} }
public setConfig(config: ButtonCardConfig): void { public setConfig(config: ButtonCardConfig): void {
if (!config.entity) {
throw new Error("Entity must be specified");
}
if (config.entity && !isValidEntityId(config.entity)) { if (config.entity && !isValidEntityId(config.entity)) {
throw new Error("Invalid Entity"); throw new Error("Invalid entity");
} }
this._config = { this._config = {

View File

@ -83,7 +83,7 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
public setConfig(config: CalendarCardConfig): void { public setConfig(config: CalendarCardConfig): void {
if (!config.entities?.length) { if (!config.entities?.length) {
throw new Error("Entities must be defined"); throw new Error("Entities must be specified");
} }
if (!Array.isArray(config.entities)) { if (!Array.isArray(config.entities)) {

View File

@ -28,7 +28,7 @@ class HuiConditionalCard extends HuiConditionalBase implements LovelaceCard {
this.validateConfig(config); this.validateConfig(config);
if (!config.card) { if (!config.card) {
throw new Error("No card configured."); throw new Error("No card configured");
} }
this._element = this._createCardElement(config.card); this._element = this._createCardElement(config.card);

View File

@ -111,6 +111,10 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
} }
public setConfig(config: EntitiesCardConfig): void { public setConfig(config: EntitiesCardConfig): void {
if (!config || !config.entities.length) {
throw new Error("Entities must be specified");
}
const entities = processConfigEntities(config.entities); const entities = processConfigEntities(config.entities);
this._config = config; this._config = config;

View File

@ -68,8 +68,11 @@ export class HuiEntityCard extends LitElement implements LovelaceCard {
private _footerElement?: HuiErrorCard | LovelaceHeaderFooter; private _footerElement?: HuiErrorCard | LovelaceHeaderFooter;
public setConfig(config: EntityCardConfig): void { public setConfig(config: EntityCardConfig): void {
if (!config.entity) {
throw new Error("Entity must be specified");
}
if (config.entity && !isValidEntityId(config.entity)) { if (config.entity && !isValidEntityId(config.entity)) {
throw new Error("Invalid Entity"); throw new Error("Invalid entity");
} }
this._config = config; this._config = config;

View File

@ -36,8 +36,8 @@ class EntityFilterCard extends UpdatingElement implements LovelaceCard {
} }
public setConfig(config: EntityFilterCardConfig): void { public setConfig(config: EntityFilterCardConfig): void {
if (!config.entities || !Array.isArray(config.entities)) { if (!config.entities.length || !Array.isArray(config.entities)) {
throw new Error("entities must be specified."); throw new Error("Entities must be specified");
} }
if ( if (
@ -49,7 +49,7 @@ class EntityFilterCard extends UpdatingElement implements LovelaceCard {
Array.isArray(entity.state_filter) Array.isArray(entity.state_filter)
) )
) { ) {
throw new Error("Incorrect filter config."); throw new Error("Incorrect filter config");
} }
this._configEntities = processConfigEntities(config.entities); this._configEntities = processConfigEntities(config.entities);

View File

@ -18,6 +18,7 @@ import { isValidEntityId } from "../../../common/entity/valid_entity_id";
import "../../../components/ha-card"; import "../../../components/ha-card";
import "../../../components/ha-gauge"; import "../../../components/ha-gauge";
import type { HomeAssistant } from "../../../types"; import type { HomeAssistant } from "../../../types";
import { UNAVAILABLE } from "../../../data/entity";
import { findEntities } from "../common/find-entites"; import { findEntities } from "../common/find-entites";
import { hasConfigOrEntityChanged } from "../common/has-changed"; import { hasConfigOrEntityChanged } from "../common/has-changed";
import { createEntityNotFoundWarning } from "../components/hui-warning"; import { createEntityNotFoundWarning } from "../components/hui-warning";
@ -72,12 +73,13 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
} }
public setConfig(config: GaugeCardConfig): void { public setConfig(config: GaugeCardConfig): void {
if (!config || !config.entity) { if (!config.entity) {
throw new Error("Invalid card configuration"); throw new Error("Entity must be specified");
} }
if (!isValidEntityId(config.entity)) { if (!isValidEntityId(config.entity)) {
throw new Error("Invalid Entity"); throw new Error("Invalid entity");
} }
this._config = { min: 0, max: 100, ...config }; this._config = { min: 0, max: 100, ...config };
} }
@ -98,6 +100,18 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
const state = Number(stateObj.state); const state = Number(stateObj.state);
if (stateObj.state === UNAVAILABLE) {
return html`
<hui-warning
>${this.hass.localize(
"ui.panel.lovelace.warning.entity_unavailable",
"entity",
this._config.entity
)}</hui-warning
>
`;
}
if (isNaN(state)) { if (isNaN(state)) {
return html` return html`
<hui-warning <hui-warning

View File

@ -66,7 +66,7 @@ export class HuiHumidifierCard extends LitElement implements LovelaceCard {
public setConfig(config: HumidifierCardConfig): void { public setConfig(config: HumidifierCardConfig): void {
if (!config.entity || config.entity.split(".")[0] !== "humidifier") { if (!config.entity || config.entity.split(".")[0] !== "humidifier") {
throw new Error("Specify an entity from within the humidifier domain."); throw new Error("Specify an entity from within the humidifier domain");
} }
this._config = config; this._config = config;

View File

@ -73,7 +73,7 @@ export class HuiLightCard extends LitElement implements LovelaceCard {
public setConfig(config: LightCardConfig): void { public setConfig(config: LightCardConfig): void {
if (!config.entity || config.entity.split(".")[0] !== "light") { if (!config.entity || config.entity.split(".")[0] !== "light") {
throw new Error("Specify an entity from within the light domain."); throw new Error("Specify an entity from within the light domain");
} }
this._config = { this._config = {

View File

@ -76,6 +76,10 @@ export class HuiLogbookCard extends LitElement implements LovelaceCard {
} }
public setConfig(config: LogbookCardConfig): void { public setConfig(config: LogbookCardConfig): void {
if (!config.entities.length) {
throw new Error("Entities must be specified");
}
this._configEntities = processConfigEntities<EntityConfig>(config.entities); this._configEntities = processConfigEntities<EntityConfig>(config.entities);
this._config = { this._config = {

View File

@ -137,9 +137,9 @@ class HuiMapCard extends LitElement implements LovelaceCard {
throw new Error("Error in card configuration."); 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( 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)) { if (config.entities && !Array.isArray(config.entities)) {

View File

@ -58,7 +58,7 @@ export class HuiMarkdownCard extends LitElement implements LovelaceCard {
public setConfig(config: MarkdownCardConfig): void { public setConfig(config: MarkdownCardConfig): void {
if (!config.content) { if (!config.content) {
throw new Error("Invalid Configuration: Content Required"); throw new Error("Content required");
} }
if (this._config?.content !== config.content) { if (this._config?.content !== config.content) {

View File

@ -213,7 +213,7 @@ export class HuiMediaControlCard extends LitElement implements LovelaceCard {
public setConfig(config: MediaControlCardConfig): void { public setConfig(config: MediaControlCardConfig): void {
if (!config.entity || config.entity.split(".")[0] !== "media_player") { 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; this._config = config;

View File

@ -48,7 +48,7 @@ export class HuiPictureCard extends LitElement implements LovelaceCard {
public setConfig(config: PictureCardConfig): void { public setConfig(config: PictureCardConfig): void {
if (!config || !config.image) { if (!config || !config.image) {
throw new Error("Invalid Configuration: 'image' required"); throw new Error("Image required");
} }
this._config = config; this._config = config;

View File

@ -62,14 +62,14 @@ class HuiPictureElementsCard extends LitElement implements LovelaceCard {
public setConfig(config: PictureElementsCardConfig): void { public setConfig(config: PictureElementsCardConfig): void {
if (!config) { if (!config) {
throw new Error("Invalid Configuration"); throw new Error("Invalid configuration");
} else if ( } else if (
!(config.image || config.camera_image || config.state_image) || !(config.image || config.camera_image || config.state_image) ||
(config.state_image && !config.entity) (config.state_image && !config.entity)
) { ) {
throw new Error("Invalid Configuration: image required"); throw new Error("Image required");
} else if (!Array.isArray(config.elements)) { } else if (!Array.isArray(config.elements)) {
throw new Error("Invalid Configuration: elements required"); throw new Error("Elements required");
} }
this._config = config; this._config = config;

View File

@ -69,7 +69,7 @@ class HuiPictureEntityCard extends LitElement implements LovelaceCard {
public setConfig(config: PictureEntityCardConfig): void { public setConfig(config: PictureEntityCardConfig): void {
if (!config || !config.entity) { if (!config || !config.entity) {
throw new Error("Invalid Configuration: 'entity' required"); throw new Error("Entity must be specified");
} }
if ( if (
@ -78,7 +78,7 @@ class HuiPictureEntityCard extends LitElement implements LovelaceCard {
!config.state_image && !config.state_image &&
!config.camera_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 }; this._config = { show_name: true, show_state: true, ...config };

View File

@ -86,7 +86,7 @@ class HuiPictureGlanceCard extends LitElement implements LovelaceCard {
!(config.image || config.camera_image || config.state_image) || !(config.image || config.camera_image || config.state_image) ||
(config.state_image && !config.entity) (config.state_image && !config.entity)
) { ) {
throw new Error("Invalid card configuration"); throw new Error("Invalid configuration");
} }
const entities = processConfigEntities(config.entities); const entities = processConfigEntities(config.entities);

View File

@ -68,7 +68,7 @@ class HuiPlantStatusCard extends LitElement implements LovelaceCard {
public setConfig(config: PlantStatusCardConfig): void { public setConfig(config: PlantStatusCardConfig): void {
if (!config.entity || config.entity.split(".")[0] !== "plant") { 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; this._config = config;

View File

@ -44,7 +44,7 @@ class HuiSensorCard extends HuiEntityCard {
public setConfig(config: SensorCardConfig): void { public setConfig(config: SensorCardConfig): void {
if (!config.entity || config.entity.split(".")[0] !== "sensor") { 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; const { graph, detail, hours_to_show, ...cardConfig } = config;

View File

@ -42,7 +42,7 @@ export abstract class HuiStackCard<T extends StackCardConfig = StackCardConfig>
public setConfig(config: T): void { public setConfig(config: T): void {
if (!config || !config.cards || !Array.isArray(config.cards)) { if (!config || !config.cards || !Array.isArray(config.cards)) {
throw new Error("Card config incorrect"); throw new Error("Invalid configuration");
} }
this._config = config; this._config = config;
this._cards = config.cards.map((card) => { this._cards = config.cards.map((card) => {

View File

@ -87,7 +87,7 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
public setConfig(config: ThermostatCardConfig): void { public setConfig(config: ThermostatCardConfig): void {
if (!config.entity || config.entity.split(".")[0] !== "climate") { 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; this._config = config;

View File

@ -90,11 +90,11 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
} }
public setConfig(config: WeatherForecastCardConfig): void { public setConfig(config: WeatherForecastCardConfig): void {
if (!config || !config.entity) { if (!config.entity) {
throw new Error("Invalid card configuration"); throw new Error("Entity must be specified");
} }
if (!isValidEntityId(config.entity)) { if (!isValidEntityId(config.entity)) {
throw new Error("Invalid Entity"); throw new Error("Invalid entity");
} }
this._config = config; this._config = config;

View File

@ -27,15 +27,15 @@ export class HuiConditionalBase extends UpdatingElement {
config: ConditionalCardConfig | ConditionalRowConfig config: ConditionalCardConfig | ConditionalRowConfig
): void { ): void {
if (!config.conditions) { if (!config.conditions) {
throw new Error("No conditions configured."); throw new Error("No conditions configured");
} }
if (!Array.isArray(config.conditions)) { 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)) { if (!validateConditionalConfig(config.conditions)) {
throw new Error("Conditions are invalid."); throw new Error("Conditions are invalid");
} }
if (this.lastChild) { if (this.lastChild) {

View File

@ -17,7 +17,7 @@ export const createEntityNotFoundWarning = (
? hass.localize( ? hass.localize(
"ui.panel.lovelace.warning.entity_not_found", "ui.panel.lovelace.warning.entity_not_found",
"entity", "entity",
entityId entityId || "[empty]"
) )
: hass.localize("ui.panel.lovelace.warning.starting"); : hass.localize("ui.panel.lovelace.warning.starting");
}; };

View File

@ -197,7 +197,7 @@ export const tryCreateLovelaceElement = <
// If domain types is given, we can derive a type from "entity" // If domain types is given, we can derive a type from "entity"
(!domainTypes || !("entity" in config)) (!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; const customTag = config.type ? _getCustomTag(config.type) : undefined;
@ -219,7 +219,7 @@ export const tryCreateLovelaceElement = <
} }
if (type === undefined) { if (type === undefined) {
throw new Error("No type specified."); throw new Error("No type specified");
} }
const tag = `hui-${type}-${tagSuffix}`; const tag = `hui-${type}-${tagSuffix}`;

View File

@ -115,7 +115,7 @@ export class HuiButtonCardEditor extends LitElement
.label="${this.hass.localize( .label="${this.hass.localize(
"ui.panel.lovelace.editor.card.generic.entity" "ui.panel.lovelace.editor.card.generic.entity"
)} (${this.hass.localize( )} (${this.hass.localize(
"ui.panel.lovelace.editor.card.config.optional" "ui.panel.lovelace.editor.card.config.required"
)})" )})"
.hass=${this.hass} .hass=${this.hass}
.value=${this._entity} .value=${this._entity}

View File

@ -81,7 +81,7 @@ export class HuiEntityCardEditor extends LitElement
.label="${this.hass.localize( .label="${this.hass.localize(
"ui.panel.lovelace.editor.card.generic.entity" "ui.panel.lovelace.editor.card.generic.entity"
)} (${this.hass.localize( )} (${this.hass.localize(
"ui.panel.lovelace.editor.card.config.optional" "ui.panel.lovelace.editor.card.config.required"
)})" )})"
.hass=${this.hass} .hass=${this.hass}
.value=${this._entity} .value=${this._entity}

View File

@ -178,7 +178,7 @@ export class HuiPictureGlanceCardEditor extends LitElement
</div> </div>
<ha-entity-picker <ha-entity-picker
.label="${this.hass.localize( .label="${this.hass.localize(
"ui.panel.lovelace.editor.card.generic.entity" "ui.panel.lovelace.editor.card.picture-glance.state_entity"
)} (${this.hass.localize( )} (${this.hass.localize(
"ui.panel.lovelace.editor.card.config.optional" "ui.panel.lovelace.editor.card.config.optional"
)})" )})"

View File

@ -25,7 +25,7 @@ class HuiConditionalElement extends HTMLElement implements LovelaceElement {
!Array.isArray(config.elements) || !Array.isArray(config.elements) ||
!validateConditionalConfig(config.conditions) !validateConditionalConfig(config.conditions)
) { ) {
throw new Error("Error in card configuration."); throw new Error("Invalid configuration");
} }
if (this._elements.length > 0) { if (this._elements.length > 0) {

View File

@ -25,7 +25,7 @@ export class HuiIconElement extends LitElement implements LovelaceElement {
public setConfig(config: IconElementConfig): void { public setConfig(config: IconElementConfig): void {
if (!config.icon) { if (!config.icon) {
throw Error("Invalid Configuration: 'icon' required"); throw Error("Icon required");
} }
this._config = { hold_action: { action: "more-info" }, ...config }; this._config = { hold_action: { action: "more-info" }, ...config };

View File

@ -26,7 +26,7 @@ export class HuiImageElement extends LitElement implements LovelaceElement {
public setConfig(config: ImageElementConfig): void { public setConfig(config: ImageElementConfig): void {
if (!config) { if (!config) {
throw Error("Error in element configuration"); throw Error("Invalid configuration");
} }
this._config = { hold_action: { action: "more-info" }, ...config }; this._config = { hold_action: { action: "more-info" }, ...config };

View File

@ -24,19 +24,17 @@ export class HuiServiceButtonElement extends LitElement
public setConfig(config: ServiceButtonElementConfig): void { public setConfig(config: ServiceButtonElementConfig): void {
if (!config || !config.service) { if (!config || !config.service) {
throw Error("Invalid Configuration: 'service' required"); throw Error("Service required");
} }
[this._domain, this._service] = config.service.split(".", 2); [this._domain, this._service] = config.service.split(".", 2);
if (!this._domain) { 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) { if (!this._service) {
throw Error( throw Error("Service does not have a service name");
"Invalid Configuration: 'service' does not have a service name"
);
} }
this._config = config; this._config = config;

View File

@ -29,7 +29,7 @@ export class HuiStateBadgeElement extends LitElement
public setConfig(config: StateBadgeElementConfig): void { public setConfig(config: StateBadgeElementConfig): void {
if (!config.entity) { if (!config.entity) {
throw Error("Invalid Configuration: 'entity' required"); throw Error("Entity required");
} }
this._config = { hold_action: { action: "more-info" }, ...config }; this._config = { hold_action: { action: "more-info" }, ...config };

View File

@ -30,7 +30,7 @@ export class HuiStateIconElement extends LitElement implements LovelaceElement {
public setConfig(config: StateIconElementConfig): void { public setConfig(config: StateIconElementConfig): void {
if (!config.entity) { if (!config.entity) {
throw Error("Invalid Configuration: 'entity' required"); throw Error("Entity required");
} }
this._config = { this._config = {

View File

@ -30,7 +30,7 @@ class HuiStateLabelElement extends LitElement implements LovelaceElement {
public setConfig(config: StateLabelElementConfig): void { public setConfig(config: StateLabelElementConfig): void {
if (!config.entity) { if (!config.entity) {
throw Error("Invalid Configuration: 'entity' required"); throw Error("Entity required");
} }
this._config = { hold_action: { action: "more-info" }, ...config }; this._config = { hold_action: { action: "more-info" }, ...config };

View File

@ -24,7 +24,7 @@ class HuiClimateEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: EntityConfig): void { public setConfig(config: EntityConfig): void {
if (!config || !config.entity) { if (!config || !config.entity) {
throw new Error("Invalid Configuration: 'entity' required"); throw new Error("Entity must be specified");
} }
this._config = config; this._config = config;

View File

@ -26,7 +26,7 @@ class HuiCoverEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: EntityConfig): void { public setConfig(config: EntityConfig): void {
if (!config) { if (!config) {
throw new Error("Configuration error"); throw new Error("Invalid configuration");
} }
this._config = config; this._config = config;
} }

View File

@ -38,7 +38,7 @@ class HuiGroupEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: EntityConfig): void { public setConfig(config: EntityConfig): void {
if (!config) { if (!config) {
throw new Error("Configuration error"); throw new Error("Invalid configuration");
} }
this._config = config; this._config = config;
} }

View File

@ -21,7 +21,7 @@ class HuiHumidifierEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: EntityConfig): void { public setConfig(config: EntityConfig): void {
if (!config || !config.entity) { if (!config || !config.entity) {
throw new Error("Invalid Configuration: 'entity' required"); throw new Error("Entity must be specified");
} }
this._config = config; this._config = config;

View File

@ -27,7 +27,7 @@ class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: EntityConfig): void { public setConfig(config: EntityConfig): void {
if (!config) { if (!config) {
throw new Error("Configuration error"); throw new Error("Invalid configuration");
} }
this._config = config; this._config = config;
} }

View File

@ -32,7 +32,7 @@ class HuiInputNumberEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: EntityConfig): void { public setConfig(config: EntityConfig): void {
if (!config) { if (!config) {
throw new Error("Configuration error"); throw new Error("Invalid configuration");
} }
this._config = config; this._config = config;
} }

View File

@ -40,7 +40,7 @@ class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: EntitiesCardEntityConfig): void { public setConfig(config: EntitiesCardEntityConfig): void {
if (!config || !config.entity) { if (!config || !config.entity) {
throw new Error("Invalid Configuration: 'entity' required"); throw new Error("Entity must be specified");
} }
this._config = config; this._config = config;

View File

@ -24,7 +24,7 @@ class HuiInputTextEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: EntityConfig): void { public setConfig(config: EntityConfig): void {
if (!config) { if (!config) {
throw new Error("Configuration error"); throw new Error("Invalid configuration");
} }
this._config = config; this._config = config;
} }

View File

@ -25,7 +25,7 @@ class HuiLockEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: EntityConfig): void { public setConfig(config: EntityConfig): void {
if (!config) { if (!config) {
throw new Error("Configuration error"); throw new Error("Invalid configuration");
} }
this._config = config; this._config = config;
} }

View File

@ -51,7 +51,7 @@ class HuiMediaPlayerEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: EntityConfig): void { public setConfig(config: EntityConfig): void {
if (!config || !config.entity) { if (!config || !config.entity) {
throw new Error("Invalid Configuration: 'entity' required"); throw new Error("Entity must be specified");
} }
this._config = config; this._config = config;

View File

@ -27,7 +27,7 @@ class HuiSceneEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: ActionRowConfig): void { public setConfig(config: ActionRowConfig): void {
if (!config) { if (!config) {
throw new Error("Configuration error"); throw new Error("Invalid configuration");
} }
this._config = config; this._config = config;
} }

View File

@ -26,7 +26,7 @@ class HuiScriptEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: ActionRowConfig): void { public setConfig(config: ActionRowConfig): void {
if (!config) { if (!config) {
throw new Error("Configuration error"); throw new Error("Invalid configuration");
} }
this._config = config; this._config = config;
} }

View File

@ -36,7 +36,7 @@ class HuiSensorEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: SensorEntityConfig): void { public setConfig(config: SensorEntityConfig): void {
if (!config) { if (!config) {
throw new Error("Configuration error"); throw new Error("Invalid configuration");
} }
this._config = config; this._config = config;
} }

View File

@ -32,7 +32,7 @@ class HuiTextEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: EntitiesCardEntityConfig): void { public setConfig(config: EntitiesCardEntityConfig): void {
if (!config) { if (!config) {
throw new Error("Configuration error"); throw new Error("Invalid configuration");
} }
this._config = config; this._config = config;
} }

View File

@ -28,7 +28,7 @@ class HuiTimerEntityRow extends LitElement {
public setConfig(config: EntityConfig): void { public setConfig(config: EntityConfig): void {
if (!config) { if (!config) {
throw new Error("Configuration error"); throw new Error("Invalid configuration");
} }
this._config = config; this._config = config;
} }

View File

@ -24,7 +24,7 @@ class HuiToggleEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: EntityConfig): void { public setConfig(config: EntityConfig): void {
if (!config) { if (!config) {
throw new Error("Configuration error"); throw new Error("Invalid configuration");
} }
this._config = config; this._config = config;
} }

View File

@ -44,7 +44,7 @@ class HuiWeatherEntityRow extends LitElement implements LovelaceRow {
public setConfig(config: EntitiesCardEntityConfig): void { public setConfig(config: EntitiesCardEntityConfig): void {
if (!config?.entity) { if (!config?.entity) {
throw new Error("Invalid Configuration: 'entity' required"); throw new Error("Entity must be specified");
} }
this._config = config; this._config = config;

View File

@ -80,9 +80,7 @@ export class HuiGraphHeaderFooter extends LitElement
public setConfig(config: GraphHeaderFooterConfig): void { public setConfig(config: GraphHeaderFooterConfig): void {
if (!config?.entity || config.entity.split(".")[0] !== "sensor") { if (!config?.entity || config.entity.split(".")[0] !== "sensor") {
throw new Error( throw new Error("Specify an entity from within the sensor domain");
"Invalid Configuration: An entity from within the sensor domain required"
);
} }
const cardConfig = { const cardConfig = {

View File

@ -41,7 +41,7 @@ export class HuiPictureHeaderFooter extends LitElement
public setConfig(config: PictureHeaderFooterConfig): void { public setConfig(config: PictureHeaderFooterConfig): void {
if (!config || !config.image) { if (!config || !config.image) {
throw new Error("Invalid Configuration: 'image' required"); throw new Error("Image required");
} }
this._config = config; this._config = config;

View File

@ -23,13 +23,13 @@ class HuiAttributeRow extends LitElement implements LovelaceRow {
public setConfig(config: AttributeRowConfig): void { public setConfig(config: AttributeRowConfig): void {
if (!config) { if (!config) {
throw new Error("Configuration error"); throw new Error("Invalid configuration");
} }
if (!config.entity) { if (!config.entity) {
throw new Error("Entity not defined"); throw new Error("Entity not specified");
} }
if (!config.attribute) { if (!config.attribute) {
throw new Error("Attribute not defined"); throw new Error("Attribute not specified");
} }
this._config = config; this._config = config;
} }

View File

@ -26,11 +26,11 @@ export class HuiButtonRow extends LitElement implements LovelaceRow {
public setConfig(config: ButtonRowConfig): void { public setConfig(config: ButtonRowConfig): void {
if (!config) { if (!config) {
throw new Error("Error in card configuration."); throw new Error("Invalid configuration");
} }
if (!config.name) { if (!config.name) {
throw new Error("Error in card configuration. No name specified."); throw new Error("No name specified");
} }
this._config = { this._config = {

View File

@ -8,15 +8,15 @@ export class HuiCallServiceRow extends HuiButtonRow {
const callServiceConfig: CallServiceConfig = config; const callServiceConfig: CallServiceConfig = config;
if (!callServiceConfig) { if (!callServiceConfig) {
throw new Error("Error in card configuration."); throw new Error("Invalid configuration");
} }
if (!callServiceConfig.name) { if (!callServiceConfig.name) {
throw new Error("Error in card configuration. No name specified."); throw new Error("No name specified");
} }
if (!callServiceConfig.service) { if (!callServiceConfig.service) {
throw new Error("Error in card configuration. No service specified."); throw new Error("No service specified");
} }
super.setConfig({ super.setConfig({

View File

@ -32,7 +32,7 @@ class HuiCastRow extends LitElement implements LovelaceRow {
public setConfig(config: CastConfig): void { public setConfig(config: CastConfig): void {
if (!config || config.view === undefined || config.view === null) { if (!config || config.view === undefined || config.view === null) {
throw new Error("Invalid Configuration: 'view' required"); throw new Error("View required");
} }
this._config = { this._config = {

View File

@ -9,7 +9,7 @@ class HuiConditionalRow extends HuiConditionalBase implements LovelaceRow {
this.validateConfig(config); this.validateConfig(config);
if (!config.row) { if (!config.row) {
throw new Error("No row configured."); throw new Error("No row configured");
} }
this._element = createRowElement(config.row) as LovelaceRow; this._element = createRowElement(config.row) as LovelaceRow;

View File

@ -19,7 +19,7 @@ class HuiSectionRow extends LitElement implements LovelaceRow {
public setConfig(config: SectionConfig): void { public setConfig(config: SectionConfig): void {
if (!config) { if (!config) {
throw new Error("Error in card configuration."); throw new Error("Invalid configuration");
} }
this._config = config; this._config = config;

View File

@ -16,7 +16,7 @@ class HuiTextRow extends LitElement implements LovelaceRow {
public setConfig(config: TextConfig): void { public setConfig(config: TextConfig): void {
if (!config || !config.name || !config.text) { 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; this._config = config;

View File

@ -19,7 +19,7 @@ class HuiWeblinkRow extends LitElement implements LovelaceRow {
public setConfig(config: WeblinkConfig): void { public setConfig(config: WeblinkConfig): void {
if (!config || !config.url) { if (!config || !config.url) {
throw new Error("Invalid Configuration: 'url' required"); throw new Error("URL required");
} }
this._config = { this._config = {

View File

@ -65,7 +65,7 @@
"unknown": "Unk", "unknown": "Unk",
"unavailable": "Unavai", "unavailable": "Unavai",
"error": "Error", "error": "Error",
"entity_not_found": "Entity Not Found" "entity_not_found": "Entity not found"
}, },
"alarm_control_panel": { "alarm_control_panel": {
"armed": "Armed", "armed": "Armed",
@ -1959,8 +1959,8 @@
"hub": "Connected via", "hub": "Connected via",
"firmware": "Firmware: {version}", "firmware": "Firmware: {version}",
"unnamed_entry": "Unnamed entry", "unnamed_entry": "Unnamed entry",
"device_unavailable": "device unavailable", "device_unavailable": "Device unavailable",
"entity_unavailable": "entity unavailable", "entity_unavailable": "Entity unavailable",
"area": "In {area}", "area": "In {area}",
"no_area": "No Area" "no_area": "No Area"
}, },
@ -2721,7 +2721,8 @@
}, },
"picture-glance": { "picture-glance": {
"name": "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": { "plant-status": {
"name": "Plant Status", "name": "Plant Status",
@ -2795,7 +2796,7 @@
"attribute_not_found": "Attribute {attribute} not available in: {entity}", "attribute_not_found": "Attribute {attribute} not available in: {entity}",
"entity_not_found": "Entity not available: {entity}", "entity_not_found": "Entity not available: {entity}",
"entity_non_numeric": "Entity is non-numeric: {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" "starting": "Home Assistant is starting, not everything may be available yet"
}, },
"changed_toast": { "changed_toast": {