@@ -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/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/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 36236dffcc..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: {
@@ -82,16 +81,13 @@ class HaPanelDevStatistics extends LitElement {
issue.data
) || issue.type
)
- : ""}`,
+ : "No issues"}`,
},
fix: {
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/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/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}
>