From 1793c68aae5ae012d6c754adf05234fcabc776fc Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 4 Oct 2021 21:04:45 -0700 Subject: [PATCH 1/6] Split price validation errors (#10155) --- src/translations/en.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/translations/en.json b/src/translations/en.json index 9757d2ffa5..75098c53d8 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -1091,10 +1091,14 @@ "title": "Unexpected unit of measurement", "description": "The following entities do not have the expected units of measurement 'kWh', 'm³' or 'ft³':" }, - "entity_unexpected_unit_price": { + "entity_unexpected_unit_energy_price": { "title": "Unexpected unit of measurement", "description": "The following entities do not have the expected units of measurement ''{currency}/kWh'' or ''{currency}/Wh'':" }, + "entity_unexpected_unit_gas_price": { + "title": "Unexpected unit of measurement", + "description": "The following entities do not have the expected units of measurement ''{currency}/kWh'', ''{currency}/Wh'', ''{currency}/m³'' or ''{currency}/ft³'':" + }, "entity_unexpected_state_class": { "title": "Unexpected state class", "description": "The following entities do not have the expected state class:" From 370f2eb9e4a63b1258cd0e66a436a4bbb7a07fc5 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 5 Oct 2021 17:58:56 +0200 Subject: [PATCH 2/6] Add no issues text to stats dev tools (#10158) --- .../developer-tools/statistics/developer-tools-statistics.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels/developer-tools/statistics/developer-tools-statistics.ts b/src/panels/developer-tools/statistics/developer-tools-statistics.ts index 36236dffcc..12dce6fb75 100644 --- a/src/panels/developer-tools/statistics/developer-tools-statistics.ts +++ b/src/panels/developer-tools/statistics/developer-tools-statistics.ts @@ -82,7 +82,7 @@ class HaPanelDevStatistics extends LitElement { issue.data ) || issue.type ) - : ""}`, + : "No issues"}`, }, fix: { title: "", From c44624282ce92be884b6bf28226c748113a95061 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 5 Oct 2021 18:11:02 +0200 Subject: [PATCH 3/6] Fix lint warnings (#10157) --- .eslintrc.json | 3 +- .../ha-selector/ha-selector-device.ts | 6 +-- .../ha-selector/ha-selector-entity.ts | 6 +-- .../ha-selector/ha-selector-target.ts | 19 +++++---- .../config/automation/ha-automation-editor.ts | 6 +-- .../config/automation/ha-automation-picker.ts | 6 +-- .../config/automation/ha-automation-trace.ts | 8 +++- .../automation/thingtalk/dialog-thingtalk.ts | 6 +-- .../thingtalk/ha-thingtalk-placeholders.ts | 1 + .../config/blueprint/ha-blueprint-overview.ts | 20 +++++----- .../zha/zha-network-visualization-page.ts | 6 +-- src/panels/config/scene/ha-scene-dashboard.ts | 6 +-- src/panels/config/scene/ha-scene-editor.ts | 6 +-- src/panels/config/script/ha-script-editor.ts | 6 +-- src/panels/config/script/ha-script-picker.ts | 6 +-- src/panels/config/script/ha-script-trace.ts | 6 ++- src/panels/config/tags/ha-config-tags.ts | 40 ++++++++++--------- .../statistics/developer-tools-statistics.ts | 11 ++--- .../card-editor/hui-dialog-create-card.ts | 3 +- 19 files changed, 88 insertions(+), 83 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 20f8188b31..407ef663dd 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -111,8 +111,7 @@ ], "unused-imports/no-unused-imports": "error", "lit/attribute-value-entities": "off", - "lit/no-template-map": "off", - "lit/no-template-arrow": "warn" + "lit/no-template-map": "off" }, "plugins": ["disable", "unused-imports"], "processor": "disable/disable" diff --git a/src/components/ha-selector/ha-selector-device.ts b/src/components/ha-selector/ha-selector-device.ts index bdf945899c..60da624665 100644 --- a/src/components/ha-selector/ha-selector-device.ts +++ b/src/components/ha-selector/ha-selector-device.ts @@ -34,7 +34,7 @@ export class HaDeviceSelector extends LitElement { .hass=${this.hass} .value=${this.value} .label=${this.label} - .deviceFilter=${(device) => this._filterDevices(device)} + .deviceFilter=${this._filterDevices} .includeDeviceClasses=${this.selector.device.entity?.device_class ? [this.selector.device.entity.device_class] : undefined} @@ -46,7 +46,7 @@ export class HaDeviceSelector extends LitElement { >`; } - private _filterDevices(device: DeviceRegistryEntry): boolean { + private _filterDevices = (device: DeviceRegistryEntry): boolean => { if ( this.selector.device?.manufacturer && device.manufacturer !== this.selector.device.manufacturer @@ -70,7 +70,7 @@ export class HaDeviceSelector extends LitElement { } } return true; - } + }; private async _loadConfigEntries() { this._configEntries = (await getConfigEntries(this.hass)).filter( diff --git a/src/components/ha-selector/ha-selector-entity.ts b/src/components/ha-selector/ha-selector-entity.ts index a2cb042c72..2facd604ba 100644 --- a/src/components/ha-selector/ha-selector-entity.ts +++ b/src/components/ha-selector/ha-selector-entity.ts @@ -27,7 +27,7 @@ export class HaEntitySelector extends SubscribeMixin(LitElement) { .hass=${this.hass} .value=${this.value} .label=${this.label} - .entityFilter=${(entity) => this._filterEntities(entity)} + .entityFilter=${this._filterEntities} .disabled=${this.disabled} allow-custom-entity >`; @@ -48,7 +48,7 @@ export class HaEntitySelector extends SubscribeMixin(LitElement) { ]; } - private _filterEntities(entity: HassEntity): boolean { + private _filterEntities = (entity: HassEntity): boolean => { if (this.selector.entity?.domain) { if (computeStateDomain(entity) !== this.selector.entity.domain) { return false; @@ -72,7 +72,7 @@ export class HaEntitySelector extends SubscribeMixin(LitElement) { } } return true; - } + }; } declare global { diff --git a/src/components/ha-selector/ha-selector-target.ts b/src/components/ha-selector/ha-selector-target.ts index 6299f60bf1..6ed0251665 100644 --- a/src/components/ha-selector/ha-selector-target.ts +++ b/src/components/ha-selector/ha-selector-target.ts @@ -69,10 +69,9 @@ export class HaTargetSelector extends SubscribeMixin(LitElement) { return html` this._filterDevices(device)} - .entityRegFilter=${(entity: EntityRegistryEntry) => - this._filterRegEntities(entity)} - .entityFilter=${(entity: HassEntity) => this._filterEntities(entity)} + .deviceFilter=${this._filterDevices} + .entityRegFilter=${this._filterRegEntities} + .entityFilter=${this._filterEntities} .includeDeviceClasses=${this.selector.target.entity?.device_class ? [this.selector.target.entity.device_class] : undefined} @@ -83,7 +82,7 @@ export class HaTargetSelector extends SubscribeMixin(LitElement) { >`; } - private _filterEntities(entity: HassEntity): boolean { + private _filterEntities = (entity: HassEntity): boolean => { if ( this.selector.target.entity?.integration || this.selector.target.device?.integration @@ -98,18 +97,18 @@ export class HaTargetSelector extends SubscribeMixin(LitElement) { } } return true; - } + }; - private _filterRegEntities(entity: EntityRegistryEntry): boolean { + private _filterRegEntities = (entity: EntityRegistryEntry): boolean => { if (this.selector.target.entity?.integration) { if (entity.platform !== this.selector.target.entity.integration) { return false; } } return true; - } + }; - private _filterDevices(device: DeviceRegistryEntry): boolean { + private _filterDevices = (device: DeviceRegistryEntry): boolean => { if ( this.selector.target.device?.manufacturer && device.manufacturer !== this.selector.target.device.manufacturer @@ -135,7 +134,7 @@ export class HaTargetSelector extends SubscribeMixin(LitElement) { } } return true; - } + }; private async _loadConfigEntries() { this._configEntries = (await getConfigEntries(this.hass)).filter( diff --git a/src/panels/config/automation/ha-automation-editor.ts b/src/panels/config/automation/ha-automation-editor.ts index 00ed5d2060..8ab69fa05f 100644 --- a/src/panels/config/automation/ha-automation-editor.ts +++ b/src/panels/config/automation/ha-automation-editor.ts @@ -113,7 +113,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) { .hass=${this.hass} .narrow=${this.narrow} .route=${this.route} - .backCallback=${() => this._backTapped()} + .backCallback=${this._backTapped} .tabs=${configSections.automation} > { if (this._dirty) { showConfirmationDialog(this, { text: this.hass!.localize( @@ -448,7 +448,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) { } else { history.back(); } - } + }; private async _duplicate() { if (this._dirty) { diff --git a/src/panels/config/automation/ha-automation-picker.ts b/src/panels/config/automation/ha-automation-picker.ts index 45de3dae36..21eedd5009 100644 --- a/src/panels/config/automation/ha-automation-picker.ts +++ b/src/panels/config/automation/ha-automation-picker.ts @@ -135,7 +135,7 @@ class HaAutomationPicker extends LitElement { template: (_info, automation: any) => html` this._runActions(ev)} + @click=${this._runActions} .disabled=${UNAVAILABLE_STATES.includes(automation.state)} > ${this.hass.localize("ui.card.automation.trigger")} @@ -313,10 +313,10 @@ class HaAutomationPicker extends LitElement { }); } - private _runActions(ev) { + private _runActions = (ev) => { const entityId = ev.currentTarget.automation.entity_id; triggerAutomationActions(this.hass, entityId); - } + }; private _createNew() { if ( diff --git a/src/panels/config/automation/ha-automation-trace.ts b/src/panels/config/automation/ha-automation-trace.ts index b4ba49cc05..c4066847cb 100644 --- a/src/panels/config/automation/ha-automation-trace.ts +++ b/src/panels/config/automation/ha-automation-trace.ts @@ -90,7 +90,7 @@ export class HaAutomationTrace extends LitElement { } const actionButtons = html` - this._loadTraces()}> + ${this.narrow - ? html` ${title} + ? html`${title}
${actionButtons}
` : ""}
@@ -335,6 +335,10 @@ export class HaAutomationTrace extends LitElement { this._selected = ev.detail; } + private _refreshTraces() { + this._loadTraces(); + } + private async _loadTraces(runId?: string) { this._traces = await loadTraces(this.hass, "automation", this.automationId); // Newest will be on top. diff --git a/src/panels/config/automation/thingtalk/dialog-thingtalk.ts b/src/panels/config/automation/thingtalk/dialog-thingtalk.ts index d42730a2ee..3c6752ad46 100644 --- a/src/panels/config/automation/thingtalk/dialog-thingtalk.ts +++ b/src/panels/config/automation/thingtalk/dialog-thingtalk.ts @@ -78,7 +78,7 @@ class DialogThingtalk extends LitElement { .hass=${this.hass} .placeholders=${this._placeholders} .opened=${this._opened} - .skip=${() => this._skip()} + .skip=${this._skip} @opened-changed=${this._openedChanged} @placeholders-filled=${this._handlePlaceholders} > @@ -229,10 +229,10 @@ class DialogThingtalk extends LitElement { this.closeDialog(); } - private _skip() { + private _skip = () => { this._params!.callback(undefined); this.closeDialog(); - } + }; private _openedChanged(ev: PolymerChangedEvent): void { if (!ev.detail.value) { diff --git a/src/panels/config/automation/thingtalk/ha-thingtalk-placeholders.ts b/src/panels/config/automation/thingtalk/ha-thingtalk-placeholders.ts index 0e06c744af..0f62bb0f39 100644 --- a/src/panels/config/automation/thingtalk/ha-thingtalk-placeholders.ts +++ b/src/panels/config/automation/thingtalk/ha-thingtalk-placeholders.ts @@ -1,3 +1,4 @@ +/* eslint-disable lit/no-template-arrow */ import { HassEntity } from "home-assistant-js-websocket"; import { css, diff --git a/src/panels/config/blueprint/ha-blueprint-overview.ts b/src/panels/config/blueprint/ha-blueprint-overview.ts index 71b071b208..e5bfb0c997 100644 --- a/src/panels/config/blueprint/ha-blueprint-overview.ts +++ b/src/panels/config/blueprint/ha-blueprint-overview.ts @@ -127,13 +127,13 @@ class HaBlueprintOverview extends LitElement { title=${this.hass.localize( "ui.panel.config.blueprint.overview.use_blueprint" )} - @click=${(ev) => this._createNew(ev)} + @click=${this._createNew} > ` : html` this._createNew(ev)} + @click=${this._createNew} > ${this.hass.localize( "ui.panel.config.blueprint.overview.use_blueprint" @@ -154,7 +154,7 @@ class HaBlueprintOverview extends LitElement { ? "ui.panel.config.blueprint.overview.share_blueprint" : "ui.panel.config.blueprint.overview.share_blueprint_no_url" )} - @click=${(ev) => this._share(ev)} + @click=${this._share} >`, }, @@ -169,7 +169,7 @@ class HaBlueprintOverview extends LitElement { .label=${this.hass.localize( "ui.panel.config.blueprint.overview.delete_blueprint" )} - @click=${(ev) => this._delete(ev)} + @click=${this._delete} >`, }, @@ -275,12 +275,12 @@ class HaBlueprintOverview extends LitElement { fireEvent(this, "reload-blueprints"); } - private _createNew(ev) { + private _createNew = (ev) => { const blueprint = ev.currentTarget.blueprint as BlueprintMetaDataPath; createNewFunctions[blueprint.domain](blueprint); - } + }; - private _share(ev) { + private _share = (ev) => { const blueprint = ev.currentTarget.blueprint; const params = new URLSearchParams(); params.append("redirect", "blueprint_import"); @@ -288,9 +288,9 @@ class HaBlueprintOverview extends LitElement { window.open( `https://my.home-assistant.io/create-link/?${params.toString()}` ); - } + }; - private async _delete(ev) { + private _delete = async (ev) => { const blueprint = ev.currentTarget.blueprint; if ( !(await showConfirmationDialog(this, { @@ -306,7 +306,7 @@ class HaBlueprintOverview extends LitElement { } await deleteBlueprint(this.hass, blueprint.domain, blueprint.path); fireEvent(this, "reload-blueprints"); - } + }; static get styles(): CSSResultGroup { return haStyle; diff --git a/src/panels/config/integrations/integration-panels/zha/zha-network-visualization-page.ts b/src/panels/config/integrations/integration-panels/zha/zha-network-visualization-page.ts index 9923da8054..737f504a2f 100644 --- a/src/panels/config/integrations/integration-panels/zha/zha-network-visualization-page.ts +++ b/src/panels/config/integrations/integration-panels/zha/zha-network-visualization-page.ts @@ -173,7 +173,7 @@ export class ZHANetworkVisualizationPage extends LitElement { .label=${this.hass.localize( "ui.panel.config.zha.visualization.zoom_label" )} - .deviceFilter=${(device) => this._filterDevices(device)} + .deviceFilter=${this._filterDevices} @value-changed=${this._onZoomToDevice} >
@@ -359,7 +359,7 @@ export class ZHANetworkVisualizationPage extends LitElement { await refreshTopology(this.hass); } - private _filterDevices(device: DeviceRegistryEntry): boolean { + private _filterDevices = (device: DeviceRegistryEntry): boolean => { if (!this.hass) { return false; } @@ -371,7 +371,7 @@ export class ZHANetworkVisualizationPage extends LitElement { } } return false; - } + }; private _handleCheckboxChange(ev: Event) { this._autoZoom = (ev.target as HaCheckbox).checked; diff --git a/src/panels/config/scene/ha-scene-dashboard.ts b/src/panels/config/scene/ha-scene-dashboard.ts index 7e16e04578..a3399fc85a 100644 --- a/src/panels/config/scene/ha-scene-dashboard.ts +++ b/src/panels/config/scene/ha-scene-dashboard.ts @@ -77,7 +77,7 @@ class HaSceneDashboard extends LitElement { title=${this.hass.localize( "ui.panel.config.scene.picker.activate_scene" )} - @click=${(ev: Event) => this._activateScene(ev)} + @click=${this._activateScene} > @@ -213,7 +213,7 @@ class HaSceneDashboard extends LitElement { fireEvent(this, "hass-more-info", { entityId }); } - private async _activateScene(ev) { + private _activateScene = async (ev) => { ev.stopPropagation(); const scene = ev.currentTarget.scene as SceneEntity; await activateScene(this.hass, scene.entity_id); @@ -225,7 +225,7 @@ class HaSceneDashboard extends LitElement { ), }); forwardHaptic("light"); - } + }; private _showHelp() { showAlertDialog(this, { diff --git a/src/panels/config/scene/ha-scene-editor.ts b/src/panels/config/scene/ha-scene-editor.ts index 460c04b4bd..6c51a61af4 100644 --- a/src/panels/config/scene/ha-scene-editor.ts +++ b/src/panels/config/scene/ha-scene-editor.ts @@ -201,7 +201,7 @@ export class HaSceneEditor extends SubscribeMixin( .hass=${this.hass} .narrow=${this.narrow} .route=${this.route} - .backCallback=${() => this._backTapped()} + .backCallback=${this._backTapped} .tabs=${configSections.automation} > { if (this._dirty) { showConfirmationDialog(this, { text: this.hass!.localize( @@ -711,7 +711,7 @@ export class HaSceneEditor extends SubscribeMixin( } else { this._goBack(); } - } + }; private _goBack(): void { applyScene(this.hass, this._storedStates); diff --git a/src/panels/config/script/ha-script-editor.ts b/src/panels/config/script/ha-script-editor.ts index 5830b81e45..ccba2b3ecd 100644 --- a/src/panels/config/script/ha-script-editor.ts +++ b/src/panels/config/script/ha-script-editor.ts @@ -87,7 +87,7 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { .hass=${this.hass} .narrow=${this.narrow} .route=${this.route} - .backCallback=${() => this._backTapped()} + .backCallback=${this._backTapped} .tabs=${configSections.automation} > { if (this._dirty) { showConfirmationDialog(this, { text: this.hass!.localize( @@ -591,7 +591,7 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { } else { history.back(); } - } + }; private async _duplicate() { if (this._dirty) { diff --git a/src/panels/config/script/ha-script-picker.ts b/src/panels/config/script/ha-script-picker.ts index 3cdd49aff0..c29c647d4d 100644 --- a/src/panels/config/script/ha-script-picker.ts +++ b/src/panels/config/script/ha-script-picker.ts @@ -79,7 +79,7 @@ class HaScriptPicker extends LitElement { title=${this.hass.localize( "ui.panel.config.script.picker.run_script" )} - @click=${(ev: Event) => this._runScript(ev)} + @click=${this._runScript} > @@ -234,7 +234,7 @@ class HaScriptPicker extends LitElement { this._filterValue = undefined; } - private async _runScript(ev) { + private _runScript = async (ev) => { ev.stopPropagation(); const script = ev.currentTarget.script as HassEntity; await triggerScript(this.hass, script.entity_id); @@ -245,7 +245,7 @@ class HaScriptPicker extends LitElement { computeStateName(script) ), }); - } + }; private _showInfo(ev) { ev.stopPropagation(); diff --git a/src/panels/config/script/ha-script-trace.ts b/src/panels/config/script/ha-script-trace.ts index ca0a916b92..01a6f81c74 100644 --- a/src/panels/config/script/ha-script-trace.ts +++ b/src/panels/config/script/ha-script-trace.ts @@ -88,7 +88,7 @@ export class HaScriptTrace extends LitElement { } const actionButtons = html` - this._loadTraces()}> + html` - this._openWrite((ev.currentTarget as any).tag)} + @click=${this._handleWriteClick} title=${this.hass.localize("ui.panel.config.tag.write")} > @@ -120,8 +119,7 @@ export class HaConfigTags extends SubscribeMixin(LitElement) { type: "icon-button", template: (_automation, tag: any) => html` - this._createAutomation((ev.currentTarget as any).tag)} + @click=${this._handleAutomationClick} title=${this.hass.localize("ui.panel.config.tag.create_automation")} > @@ -132,8 +130,7 @@ export class HaConfigTags extends SubscribeMixin(LitElement) { type: "icon-button", template: (_settings, tag: any) => html` - this._openDialog((ev.currentTarget as any).tag)} + @click=${this._handleEditClick} title=${this.hass.localize("ui.panel.config.tag.edit")} > @@ -209,6 +206,25 @@ export class HaConfigTags extends SubscribeMixin(LitElement) { `; } + private _handleWriteClick = (ev: Event) => + this._openWrite((ev.currentTarget as any).tag); + + private _handleAutomationClick = (ev: Event) => { + const tag = (ev.currentTarget as any).tag; + const data = { + alias: this.hass.localize( + "ui.panel.config.tag.automation_title", + "name", + tag.name || tag.id + ), + trigger: [{ platform: "tag", tag_id: tag.id } as TagTrigger], + }; + showAutomationEditor(data); + }; + + private _handleEditClick = (ev: Event) => + this._openDialog((ev.currentTarget as any).tag); + private _showHelp() { showAlertDialog(this, { title: this.hass.localize("ui.panel.config.tag.caption"), @@ -251,18 +267,6 @@ export class HaConfigTags extends SubscribeMixin(LitElement) { }); } - private _createAutomation(tag: Tag) { - const data = { - alias: this.hass.localize( - "ui.panel.config.tag.automation_title", - "name", - tag.name || tag.id - ), - trigger: [{ platform: "tag", tag_id: tag.id } as TagTrigger], - }; - showAutomationEditor(data); - } - private _addTag() { this._openDialog(); } diff --git a/src/panels/developer-tools/statistics/developer-tools-statistics.ts b/src/panels/developer-tools/statistics/developer-tools-statistics.ts index 12dce6fb75..f0d9c13504 100644 --- a/src/panels/developer-tools/statistics/developer-tools-statistics.ts +++ b/src/panels/developer-tools/statistics/developer-tools-statistics.ts @@ -41,7 +41,6 @@ class HaPanelDevStatistics extends LitElement { this._validateStatistics(); } - /* eslint-disable lit/no-template-arrow */ private _columns = memoizeOne( (localize): DataTableColumnContainer => ({ state: { @@ -88,10 +87,7 @@ class HaPanelDevStatistics extends LitElement { title: "", template: (_, data: any) => html`${data.issues - ? html` this._fixIssue(ev)} - .data=${data.issues} - > + ? html` Fix issue ` : ""}`, @@ -99,7 +95,6 @@ class HaPanelDevStatistics extends LitElement { }, }) ); - /* eslint-enable lit/no-template-arrow */ protected render() { return html` @@ -150,7 +145,7 @@ class HaPanelDevStatistics extends LitElement { }); } - private _fixIssue(ev) { + private _fixIssue = (ev) => { const issues = (ev.currentTarget.data as StatisticsValidationResult[]).sort( (itemA, itemB) => (FIX_ISSUES_ORDER[itemA.type] ?? 99) - @@ -236,7 +231,7 @@ class HaPanelDevStatistics extends LitElement { text: "Fixing this issue is not supported yet.", }); } - } + }; static get styles(): CSSResultGroup { return [ diff --git a/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts b/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts index 0c7a2a74c4..33e8e8b443 100644 --- a/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts +++ b/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts @@ -90,8 +90,7 @@ export class HuiCreateDialogCard - this._handleTabChanged(ev)} + @MDCTabBar:activated=${this._handleTabChanged} > Date: Wed, 6 Oct 2021 06:21:05 +0200 Subject: [PATCH 4/6] Some code improvements (#10156) --- build-scripts/gulp/hassio.js | 3 -- build-scripts/gulp/locale-data.js | 3 -- src/common/dom/apply_themes_on_element.ts | 2 +- src/common/string/filter/filter.ts | 6 ++-- src/components/trace/hat-trace-timeline.ts | 22 +++++++-------- src/dialogs/quick-bar/ha-quick-bar.ts | 2 +- .../config/cloud/account/cloud-remote-pref.ts | 16 ++++------- .../dialogs/dialog-energy-battery-settings.ts | 2 +- .../dialogs/dialog-energy-gas-settings.ts | 2 +- .../dialog-energy-grid-flow-settings.ts | 7 ++--- .../dialogs/dialog-energy-solar-settings.ts | 2 +- .../zwave/ha-config-zwave.js | 20 +++++++++---- .../integration-panels/zwave/zwave-groups.js | 5 ++-- .../config/logs/dialog-system-log-detail.ts | 2 +- .../energy/hui-energy-devices-graph-card.ts | 15 ---------- .../cards/energy/hui-energy-gas-graph-card.ts | 14 ---------- .../energy/hui-energy-solar-graph-card.ts | 14 ---------- .../energy/hui-energy-usage-graph-card.ts | 28 ++----------------- .../components/hui-timestamp-display.ts | 7 +---- src/panels/my/ha-panel-my.ts | 2 +- 20 files changed, 51 insertions(+), 123 deletions(-) diff --git a/build-scripts/gulp/hassio.js b/build-scripts/gulp/hassio.js index a21853d37a..696e742a05 100644 --- a/build-scripts/gulp/hassio.js +++ b/build-scripts/gulp/hassio.js @@ -1,9 +1,6 @@ const gulp = require("gulp"); -const fs = require("fs"); -const path = require("path"); const env = require("../env"); -const paths = require("../paths"); require("./clean.js"); require("./gen-icons-json.js"); diff --git a/build-scripts/gulp/locale-data.js b/build-scripts/gulp/locale-data.js index 4c085f99e2..9d572ab5b9 100755 --- a/build-scripts/gulp/locale-data.js +++ b/build-scripts/gulp/locale-data.js @@ -4,9 +4,6 @@ const del = require("del"); const path = require("path"); const gulp = require("gulp"); const fs = require("fs"); -const merge = require("gulp-merge-json"); -const rename = require("gulp-rename"); -const transform = require("gulp-json-transform"); const paths = require("../paths"); const outDir = "build/locale-data"; diff --git a/src/common/dom/apply_themes_on_element.ts b/src/common/dom/apply_themes_on_element.ts index 31027462c0..721863e7f3 100644 --- a/src/common/dom/apply_themes_on_element.ts +++ b/src/common/dom/apply_themes_on_element.ts @@ -115,7 +115,7 @@ export const applyThemesOnElement = ( } const newTheme = - themeRules && cacheKey + Object.keys(themeRules).length && cacheKey ? PROCESSED_THEMES[cacheKey] || processTheme(cacheKey, themeRules) : undefined; diff --git a/src/common/string/filter/filter.ts b/src/common/string/filter/filter.ts index fc99bc10b8..e7c0103263 100644 --- a/src/common/string/filter/filter.ts +++ b/src/common/string/filter/filter.ts @@ -180,10 +180,10 @@ export function fuzzyScore( wordLow ); - let row = 1; + let row: number; let column = 1; - let patternPos = patternStart; - let wordPos = wordStart; + let patternPos: number; + let wordPos: number; const hasStrongFirstMatch = [false]; diff --git a/src/components/trace/hat-trace-timeline.ts b/src/components/trace/hat-trace-timeline.ts index 5c00d83322..291f188691 100644 --- a/src/components/trace/hat-trace-timeline.ts +++ b/src/components/trace/hat-trace-timeline.ts @@ -511,18 +511,16 @@ export class HaAutomationTracer extends LitElement { className: isError ? "error" : undefined, }; } - // null means it was stopped by a condition - if (entry) { - entries.push(html` - - ${entry.description} - - `); - } + + entries.push(html` + + ${entry.description} + + `); return html`${entries}`; } diff --git a/src/dialogs/quick-bar/ha-quick-bar.ts b/src/dialogs/quick-bar/ha-quick-bar.ts index e081870ae8..bde8b0eba6 100644 --- a/src/dialogs/quick-bar/ha-quick-bar.ts +++ b/src/dialogs/quick-bar/ha-quick-bar.ts @@ -123,7 +123,7 @@ export class QuickBar extends LitElement { : this._entityItems; if (items && this._filter && this._filter !== " ") { - items = this._filterItems(items || [], this._filter); + items = this._filterItems(items, this._filter); } return html` diff --git a/src/panels/config/cloud/account/cloud-remote-pref.ts b/src/panels/config/cloud/account/cloud-remote-pref.ts index 528a8739bb..aeadcf80ed 100644 --- a/src/panels/config/cloud/account/cloud-remote-pref.ts +++ b/src/panels/config/cloud/account/cloud-remote-pref.ts @@ -99,16 +99,12 @@ export class CloudRemotePref extends LitElement { )} - ${remote_certificate - ? html` -
- - ${this.hass.localize( - "ui.panel.config.cloud.account.remote.certificate_info" - )} - - ` - : ""} +
+ + ${this.hass.localize( + "ui.panel.config.cloud.account.remote.certificate_info" + )} +
`; diff --git a/src/panels/config/energy/dialogs/dialog-energy-battery-settings.ts b/src/panels/config/energy/dialogs/dialog-energy-battery-settings.ts index abae57e651..61f4841168 100644 --- a/src/panels/config/energy/dialogs/dialog-energy-battery-settings.ts +++ b/src/panels/config/energy/dialogs/dialog-energy-battery-settings.ts @@ -36,7 +36,7 @@ export class DialogEnergyBatterySettings this._params = params; this._source = params.source ? { ...params.source } - : (this._source = emptyBatteryEnergyPreference()); + : emptyBatteryEnergyPreference(); } public closeDialog(): void { diff --git a/src/panels/config/energy/dialogs/dialog-energy-gas-settings.ts b/src/panels/config/energy/dialogs/dialog-energy-gas-settings.ts index 2322a3c309..102c6ab5b7 100644 --- a/src/panels/config/energy/dialogs/dialog-energy-gas-settings.ts +++ b/src/panels/config/energy/dialogs/dialog-energy-gas-settings.ts @@ -42,7 +42,7 @@ export class DialogEnergyGasSettings this._params = params; this._source = params.source ? { ...params.source } - : (this._source = emptyGasEnergyPreference()); + : emptyGasEnergyPreference(); this._costs = this._source.entity_energy_price ? "entity" : this._source.number_energy_price diff --git a/src/panels/config/energy/dialogs/dialog-energy-grid-flow-settings.ts b/src/panels/config/energy/dialogs/dialog-energy-grid-flow-settings.ts index e138e98fad..822470debe 100644 --- a/src/panels/config/energy/dialogs/dialog-energy-grid-flow-settings.ts +++ b/src/panels/config/energy/dialogs/dialog-energy-grid-flow-settings.ts @@ -46,10 +46,9 @@ export class DialogEnergyGridFlowSettings this._params = params; this._source = params.source ? { ...params.source } - : (this._source = - params.direction === "from" - ? emptyFlowFromGridSourceEnergyPreference() - : emptyFlowToGridSourceEnergyPreference()); + : params.direction === "from" + ? emptyFlowFromGridSourceEnergyPreference() + : emptyFlowToGridSourceEnergyPreference(); this._costs = this._source.entity_energy_price ? "entity" : this._source.number_energy_price diff --git a/src/panels/config/energy/dialogs/dialog-energy-solar-settings.ts b/src/panels/config/energy/dialogs/dialog-energy-solar-settings.ts index 5534ed156a..d4cdd03676 100644 --- a/src/panels/config/energy/dialogs/dialog-energy-solar-settings.ts +++ b/src/panels/config/energy/dialogs/dialog-energy-solar-settings.ts @@ -49,7 +49,7 @@ export class DialogEnergySolarSettings this._fetchSolarForecastConfigEntries(); this._source = params.source ? { ...params.source } - : (this._source = emptySolarEnergyPreference()); + : emptySolarEnergyPreference(); this._forecast = this._source.config_entry_solar_forecast !== null; } diff --git a/src/panels/config/integrations/integration-panels/zwave/ha-config-zwave.js b/src/panels/config/integrations/integration-panels/zwave/ha-config-zwave.js index 7d9fb20bcc..c873af398e 100644 --- a/src/panels/config/integrations/integration-panels/zwave/ha-config-zwave.js +++ b/src/panels/config/integrations/integration-panels/zwave/ha-config-zwave.js @@ -493,7 +493,9 @@ class HaConfigZwave extends LocalizeMixin(EventsMixin(PolymerElement)) { } computeEntities(selectedNode) { - if (!this.nodes || selectedNode === -1) return -1; + if (!this.nodes || selectedNode === -1) { + return -1; + } const nodeid = this.nodes[this.selectedNode].attributes.node_id; const hass = this.hass; return Object.keys(this.hass.states) @@ -512,7 +514,9 @@ class HaConfigZwave extends LocalizeMixin(EventsMixin(PolymerElement)) { } selectedNodeChanged(selectedNode) { - if (selectedNode === -1) return; + if (selectedNode === -1) { + return; + } this.selectedEntity = -1; this.hass @@ -573,7 +577,9 @@ class HaConfigZwave extends LocalizeMixin(EventsMixin(PolymerElement)) { } selectedEntityChanged(selectedEntity) { - if (selectedEntity === -1) return; + if (selectedEntity === -1) { + return; + } this.hass .callApi( "GET", @@ -640,12 +646,16 @@ class HaConfigZwave extends LocalizeMixin(EventsMixin(PolymerElement)) { } computeRefreshEntityServiceData(selectedEntity) { - if (selectedEntity === -1) return -1; + if (selectedEntity === -1) { + return -1; + } return { entity_id: this.entities[selectedEntity].entity_id }; } computePollIntensityServiceData(entityPollingIntensity) { - if (!this.selectedNode === -1 || this.selectedEntity === -1) return -1; + if (this.selectedNode === -1 || this.selectedEntity === -1) { + return -1; + } return { node_id: this.nodes[this.selectedNode].attributes.node_id, value_id: this.entities[this.selectedEntity].attributes.value_id, diff --git a/src/panels/config/integrations/integration-panels/zwave/zwave-groups.js b/src/panels/config/integrations/integration-panels/zwave/zwave-groups.js index 94037f1e03..129587fcfb 100644 --- a/src/panels/config/integrations/integration-panels/zwave/zwave-groups.js +++ b/src/panels/config/integrations/integration-panels/zwave/zwave-groups.js @@ -300,12 +300,13 @@ class ZwaveGroups extends LocalizeMixin(PolymerElement) { _computeAssocServiceData(selectedGroup, type) { if ( - !this.groups === -1 || + !this.groups || selectedGroup === -1 || this.selectedNode === -1 || this._selectedTargetNode === -1 - ) + ) { return -1; + } return { node_id: this.nodes[this.selectedNode].attributes.node_id, association: type, diff --git a/src/panels/config/logs/dialog-system-log-detail.ts b/src/panels/config/logs/dialog-system-log-detail.ts index cf3ace57d7..074a87eafb 100644 --- a/src/panels/config/logs/dialog-system-log-detail.ts +++ b/src/panels/config/logs/dialog-system-log-detail.ts @@ -65,7 +65,7 @@ class DialogSystemLogDetail extends LitElement { this._manifest && (this._manifest.is_built_in || // Custom components with our offical docs should not link to our docs - !this._manifest.documentation.includes("www.home-assistant.io")); + !this._manifest.documentation.includes("://www.home-assistant.io")); return html` diff --git a/src/panels/lovelace/cards/energy/hui-energy-devices-graph-card.ts b/src/panels/lovelace/cards/energy/hui-energy-devices-graph-card.ts index db0a4a86df..5d24f900d5 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-devices-graph-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-devices-graph-card.ts @@ -164,21 +164,6 @@ export class HuiEnergyDevicesGraphCard ) ); - const statisticsData = Object.values(this._data!); - let endTime: Date; - - endTime = new Date( - Math.max( - ...statisticsData.map((stats) => - stats.length ? new Date(stats[stats.length - 1].start).getTime() : 0 - ) - ) - ); - - if (!endTime || endTime > new Date()) { - endTime = new Date(); - } - const data: Array>["data"]> = []; const borderColor: string[] = []; const backgroundColor: string[] = []; diff --git a/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts b/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts index f46af3d81d..582107472e 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts @@ -220,21 +220,7 @@ export class HuiEnergyGasGraphCard this._unit = getEnergyGasUnit(this.hass, energyData.prefs) || "m³"; - const statisticsData = Object.values(energyData.stats); const datasets: ChartDataset<"bar">[] = []; - let endTime: Date; - - endTime = new Date( - Math.max( - ...statisticsData.map((stats) => - stats.length ? new Date(stats[stats.length - 1].start).getTime() : 0 - ) - ) - ); - - if (!endTime || endTime > new Date()) { - endTime = new Date(); - } const computedStyles = getComputedStyle(this); const gasColor = computedStyles diff --git a/src/panels/lovelace/cards/energy/hui-energy-solar-graph-card.ts b/src/panels/lovelace/cards/energy/hui-energy-solar-graph-card.ts index fb89e115a1..54b272cfd4 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-solar-graph-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-solar-graph-card.ts @@ -226,21 +226,7 @@ export class HuiEnergySolarGraphCard } } - const statisticsData = Object.values(energyData.stats); const datasets: ChartDataset<"bar">[] = []; - let endTime: Date; - - endTime = new Date( - Math.max( - ...statisticsData.map((stats) => - stats.length ? new Date(stats[stats.length - 1].start).getTime() : 0 - ) - ) - ); - - if (!endTime || endTime > new Date()) { - endTime = new Date(); - } const computedStyles = getComputedStyle(this); const solarColor = computedStyles diff --git a/src/panels/lovelace/cards/energy/hui-energy-usage-graph-card.ts b/src/panels/lovelace/cards/energy/hui-energy-usage-graph-card.ts index 5b08a6b08a..db2b8a0db6 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-usage-graph-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-usage-graph-card.ts @@ -88,7 +88,7 @@ export class HuiEnergyUsageGraphCard )} chart-type="bar" > - ${!this._chartData.datasets.length + ${!this._chartData.datasets.some((dataset) => dataset.data.length) ? html`
${isToday(this._start) ? "There is no data to show. It can take up to 2 hours for new data to arrive after you configure your energy dashboard." @@ -228,6 +228,8 @@ export class HuiEnergyUsageGraphCard ); private async _getStatistics(energyData: EnergyData): Promise { + const datasets: ChartDataset<"bar">[] = []; + const statistics: { to_grid?: string[]; from_grid?: string[]; @@ -283,33 +285,9 @@ export class HuiEnergyUsageGraphCard energyData.start ); - const statisticsData = Object.values(energyData.stats); - - const datasets: ChartDataset<"bar">[] = []; - let endTime: Date; - this._start = energyData.start; this._end = energyData.end || endOfToday(); - if (statisticsData.length === 0) { - this._chartData = { - datasets, - }; - return; - } - - endTime = new Date( - Math.max( - ...statisticsData.map((stats) => - stats.length ? new Date(stats[stats.length - 1].start).getTime() : 0 - ) - ) - ); - - if (endTime > new Date()) { - endTime = new Date(); - } - const combinedData: { to_grid?: { [statId: string]: { [start: string]: number } }; to_battery?: { [statId: string]: { [start: string]: number } }; diff --git a/src/panels/lovelace/components/hui-timestamp-display.ts b/src/panels/lovelace/components/hui-timestamp-display.ts index 0cd5d44de9..211ff97268 100644 --- a/src/panels/lovelace/components/hui-timestamp-display.ts +++ b/src/panels/lovelace/components/hui-timestamp-display.ts @@ -104,12 +104,7 @@ class HuiTimestampDisplay extends LitElement { this._relative = this._format === "relative" ? relativeTime(this.ts, this.hass!.locale) - : (this._relative = relativeTime( - new Date(), - this.hass!.locale, - this.ts, - false - )); + : relativeTime(new Date(), this.hass!.locale, this.ts, false); } } } diff --git a/src/panels/my/ha-panel-my.ts b/src/panels/my/ha-panel-my.ts index aa1c3aa8fd..07addd5bb5 100644 --- a/src/panels/my/ha-panel-my.ts +++ b/src/panels/my/ha-panel-my.ts @@ -218,7 +218,7 @@ class HaPanelMy extends LitElement { protected render() { if (this._error) { - let error = "Unknown error"; + let error: string; switch (this._error) { case "not_supported": error = From 2d5c8ec3e9c130e7885036b7dfaa92e31ce1b415 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 6 Oct 2021 09:43:23 +0200 Subject: [PATCH 5/6] Bumped version to 20211006.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b860bf0595..9aefef5fe2 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20211004.0", + version="20211006.0", description="The Home Assistant frontend", url="https://github.com/home-assistant/frontend", author="The Home Assistant Authors", From 2fb3ac74ebfb413df6387340be19f96f011ef4f5 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 6 Oct 2021 09:57:03 +0200 Subject: [PATCH 6/6] Add total and total increasing state class --- src/util/hass-attributes-util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/hass-attributes-util.ts b/src/util/hass-attributes-util.ts index feaf4c28fb..0d08b6ed87 100644 --- a/src/util/hass-attributes-util.ts +++ b/src/util/hass-attributes-util.ts @@ -124,7 +124,7 @@ hassAttributeUtil.LOGIC_STATE_ATTRIBUTES = { }, state_class: { type: "array", - options: { sensor: ["measurement"] }, + options: { sensor: ["measurement", "total", "total_increasing"] }, description: "State class", domains: ["sensor"], },