diff --git a/pyproject.toml b/pyproject.toml index d5ef09e5da..e4ef973631 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "home-assistant-frontend" -version = "20250702.2" +version = "20250702.3" license = "Apache-2.0" license-files = ["LICENSE*"] description = "The Home Assistant frontend" diff --git a/src/components/chart/statistics-chart.ts b/src/components/chart/statistics-chart.ts index dd60599bc2..596eb92b7d 100644 --- a/src/components/chart/statistics-chart.ts +++ b/src/components/chart/statistics-chart.ts @@ -106,6 +106,8 @@ export class StatisticsChart extends LitElement { private _computedStyle?: CSSStyleDeclaration; + private _previousYAxisLabelValue = 0; + protected shouldUpdate(changedProps: PropertyValues): boolean { return changedProps.size > 1 || !changedProps.has("hass"); } @@ -314,6 +316,9 @@ export class StatisticsChart extends LitElement { splitLine: { show: true, }, + axisLabel: { + formatter: this._formatYAxisLabel, + } as any, }, legend: { type: "custom", @@ -640,6 +645,22 @@ export class StatisticsChart extends LitElement { return Math.abs(value) < 1 ? value : roundingFn(value); } + private _formatYAxisLabel = (value: number) => { + // show the first significant digit for tiny values + const maximumFractionDigits = Math.max( + 1, + // use the difference to the previous value to determine the number of significant digits #25526 + -Math.floor( + Math.log10(Math.abs(value - this._previousYAxisLabelValue || 1)) + ) + ); + const label = formatNumber(value, this.hass.locale, { + maximumFractionDigits, + }); + this._previousYAxisLabelValue = value; + return label; + }; + static styles = css` :host { display: block; diff --git a/src/dialogs/config-flow/step-flow-create-entry.ts b/src/dialogs/config-flow/step-flow-create-entry.ts index bfc0527511..4b9eae53a7 100644 --- a/src/dialogs/config-flow/step-flow-create-entry.ts +++ b/src/dialogs/config-flow/step-flow-create-entry.ts @@ -212,7 +212,10 @@ class StepFlowCreateEntry extends LitElement { entityIds.push(...entities.map((entity) => entity.entity_id)); }); - const entityIdsMapping = getAutomaticEntityIds(this.hass, entityIds); + const entityIdsMapping = await getAutomaticEntityIds( + this.hass, + entityIds + ); Object.entries(entityIdsMapping).forEach(([oldEntityId, newEntityId]) => { if (newEntityId) { diff --git a/src/panels/config/helpers/ha-config-helpers.ts b/src/panels/config/helpers/ha-config-helpers.ts index 5e4e386f52..2548e0d2aa 100644 --- a/src/panels/config/helpers/ha-config-helpers.ts +++ b/src/panels/config/helpers/ha-config-helpers.ts @@ -74,6 +74,7 @@ import type { UpdateEntityRegistryEntryResult, } from "../../../data/entity_registry"; import { + entityRegistryByEntityId, subscribeEntityRegistry, updateEntityRegistryEntry, } from "../../../data/entity_registry"; @@ -520,9 +521,8 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) { : true ) .map((item) => { - const entityRegEntry = entityReg.find( - (reg) => reg.entity_id === item.entity_id - ); + const entityRegEntry = + entityRegistryByEntityId(entityReg)[item.entity_id]; const labels = labelReg && entityRegEntry?.labels; const category = entityRegEntry?.categories.helpers; return { @@ -547,7 +547,7 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) { private _labelsForEntity(entityId: string): string[] { return ( this.hass.entities[entityId]?.labels || - this._entityReg.find((e) => e.entity_id === entityId)?.labels || + entityRegistryByEntityId(this._entityReg)[entityId]?.labels || [] ); } @@ -885,9 +885,9 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) { const labelItems = new Set(); this._stateItems .filter((stateItem) => - this._entityReg - .find((reg) => reg.entity_id === stateItem.entity_id) - ?.labels.some((lbl) => filter.includes(lbl)) + entityRegistryByEntityId(this._entityReg)[ + stateItem.entity_id + ]?.labels.some((lbl) => filter.includes(lbl)) ) .forEach((stateItem) => labelItems.add(stateItem.entity_id)); (this._disabledEntityEntries || []) @@ -913,9 +913,8 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) { .filter( (stateItem) => filter[0] === - this._entityReg.find( - (reg) => reg.entity_id === stateItem.entity_id - )?.categories.helpers + entityRegistryByEntityId(this._entityReg)[stateItem.entity_id] + ?.categories.helpers ) .forEach((stateItem) => categoryItems.add(stateItem.entity_id)); (this._disabledEntityEntries || []) @@ -943,9 +942,9 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) { } private _editCategory(helper: any) { - const entityReg = this._entityReg.find( - (reg) => reg.entity_id === helper.entity_id - ); + const entityReg = entityRegistryByEntityId(this._entityReg)[ + helper.entity_id + ]; if (!entityReg) { showAlertDialog(this, { title: this.hass.localize( diff --git a/src/panels/config/integrations/ha-config-entry-device-row.ts b/src/panels/config/integrations/ha-config-entry-device-row.ts index 6783240f46..69afc14122 100644 --- a/src/panels/config/integrations/ha-config-entry-device-row.ts +++ b/src/panels/config/integrations/ha-config-entry-device-row.ts @@ -115,9 +115,7 @@ class HaConfigEntryDeviceRow extends LitElement { : nothing} ${entities.length ? html` - + entity.entity_id) ); diff --git a/src/panels/config/integrations/integration-panels/zwave_js/add-node/dialog-zwave_js-add-node.ts b/src/panels/config/integrations/integration-panels/zwave_js/add-node/dialog-zwave_js-add-node.ts index 561cf10848..5b9bb819d8 100644 --- a/src/panels/config/integrations/integration-panels/zwave_js/add-node/dialog-zwave_js-add-node.ts +++ b/src/panels/config/integrations/integration-panels/zwave_js/add-node/dialog-zwave_js-add-node.ts @@ -878,7 +878,7 @@ class DialogZWaveJSAddNode extends SubscribeMixin(LitElement) { (entity) => entity.device_id === this._device!.id ); - const entityIdsMapping = getAutomaticEntityIds( + const entityIdsMapping = await getAutomaticEntityIds( this.hass, entities.map((entity) => entity.entity_id) ); diff --git a/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-remove-node.ts b/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-remove-node.ts index 58e88b3c00..2bbb6d13fe 100644 --- a/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-remove-node.ts +++ b/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-remove-node.ts @@ -323,7 +323,7 @@ class DialogZWaveJSRemoveNode extends LitElement { this._subscribed.then((unsub) => unsub && unsub()); this._subscribed = undefined; } - if (this._step === "exclusion") { + if (this._step === "exclusion" && this._entryId) { this._stopExclusion(); } if (this._removeNodeTimeoutHandle) { @@ -332,6 +332,7 @@ class DialogZWaveJSRemoveNode extends LitElement { }; public closeDialog(): void { + this._unsubscribe(); this._entryId = undefined; }