Compare commits

...

9 Commits

Author SHA1 Message Date
Franck Nijhof d4ec72006d Use singular verb in numeric state trigger summary (#52592)
The numeric state trigger summary joins multiple entities with "or" but
switched the English verb to plural, reading "If A or B are above X". With
"or" the trigger fires when any one entity crosses the threshold, so English
uses singular agreement: "If A or B is above X".

Make both plural branches render "is" in the three English numeric_state
trigger description strings. The numberOfEntities placeholder is kept (not
replaced by a static "is") so it stays visible in the source language and
translators can keep using plural agreement where their grammar needs it.
The numeric_state condition is unchanged: it joins entities with "and" and
requires all to match.
2026-06-13 21:12:16 +02:00
renovate[bot] 393d6a8a0a Update rspack monorepo to v2.0.8 (#52595)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-13 20:42:51 +02:00
Franck Nijhof 4a030884f5 Skip entities table list rebuild on plain state changes (#52586)
While the entities configuration table is open, willUpdate rebuilt the
list of entities without a unique id on every hass update. Because each
state update produces a new states object, the oldHass.states !==
this.hass.states guard was always true, so on every state tick the panel
allocated a Set over all registry entities, iterated every state, and built
StateEntity objects, then discarded the result unless a non-registry entity
had actually been added.

Detect a newly added entity up front and only enter the rebuild when the
set of entity ids could have changed (or a registry, entity-sources, or
exposed-entities dependency changed). A plain state value change on an
existing entity can no longer trigger the rebuild. Behavior is unchanged:
the inner assignment already only ran when an entity was added.
2026-06-13 17:13:09 +02:00
pcan08 f65596cad8 Align apps page search bar style with integrations page (#52581)
Align apps installed search bar style with integrations dashboard

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 17:09:53 +02:00
Franck Nijhof 1449c17fd1 Hoist per-call allocations out of computeStateDisplay (#52585)
computeStateToPartsFromEntityAttributes runs for essentially every entity
state that is rendered, but it rebuilt several constants on every call: a
3-element domain array, a 15-element timestamp-domain array (both only used
for an includes() check), and the monetary part-type map.

Move these to module-level Set/object constants (matching the existing
STATE_COLORED_DOMAIN pattern in state_color.ts) and use Set.has(). Behavior
is unchanged; the domain lists are now named and documented.
2026-06-13 17:01:41 +02:00
Franck Nijhof ce0e6a7665 Cache Intl.NumberFormat instances in formatNumber (#52583)
formatNumberToParts, the engine behind formatNumber, built a new
Intl.NumberFormat on every call. It is invoked for essentially every
numeric state render, and constructing an Intl.NumberFormat is
comparatively expensive.

Cache the formatters in a Map keyed by (locale, options). Unlike the
single-entry memoizeOne used for the date formatters, the number format
options are derived per value, so a multi-entry cache is needed to avoid
thrashing. The number of distinct combinations is small and bounded in
practice. Output is unchanged.
2026-06-13 17:01:33 +02:00
Franck Nijhof 460dace974 Speed up bulk selection in data table (#52589)
select() looked up each id with a find over all filtered rows and checked
membership with includes on the growing checked-rows array, making a large
batch selection O(rows x ids) plus O(ids squared).

Build a row lookup Map once and track membership with a Set, dropping the
batch selection to O(rows + ids). Behavior is unchanged.
2026-06-13 16:58:37 +02:00
Franck Nijhof 7111d8a8a8 Auto-select first voice in required TTS voice picker (#52576)
When a voice was required and no value was set, the picker displayed the
first voice in the dropdown but kept its own value undefined and never
fired a value-changed event. As a result, the parent (for example the TTS
test card in the media browser) never learned the voice: the selected
voice id footer stayed hidden and no voice was sent on synthesis. This was
most noticeable for languages with a single available voice, where the
selection could not be changed to force an event.

Auto-select and emit the first voice when one is required and the current
value is missing or no longer valid for the loaded voices, so the value
matches what the dropdown shows. Non-required usages keep clearing the
value as before.
2026-06-13 16:51:57 +02:00
Franck Nijhof b96d1f2809 Center the to-do list reorder drag handle (#52582)
The reorder handle lives in the mwc list item meta slot, which is a fixed
24px tall box. The handle's vertical padding of 16px made the icon 56px
tall, overflowing that box and pushing the drag icon visually below the
row center.

Remove the vertical padding so the 24px icon fits the 24px meta slot and
stays centered. The horizontal padding is kept unchanged.
2026-06-13 16:51:18 +02:00
11 changed files with 177 additions and 100 deletions
+1 -1
View File
@@ -137,7 +137,7 @@
"@octokit/plugin-retry": "8.1.0",
"@octokit/rest": "22.0.1",
"@rsdoctor/rspack-plugin": "1.5.12",
"@rspack/core": "2.0.6",
"@rspack/core": "2.0.8",
"@rspack/dev-server": "2.0.3",
"@types/chromecast-caf-receiver": "6.0.26",
"@types/chromecast-caf-sender": "1.0.11",
+37 -30
View File
@@ -19,6 +19,40 @@ import type { LocalizeFunc } from "../translations/localize";
import { computeDomain } from "./compute_domain";
import { SENSOR_TIMESTAMP_DEVICE_CLASSES } from "../../data/sensor";
// Domains whose state is a timezone-agnostic date and/or time string.
const DATE_TIME_DOMAINS = new Set(["date", "input_datetime", "time"]);
// Domains whose state is a timestamp.
const TIMESTAMP_DOMAINS = new Set([
"ai_task",
"button",
"conversation",
"event",
"image",
"infrared",
"input_button",
"notify",
"radio_frequency",
"scene",
"stt",
"tag",
"tts",
"wake_word",
"datetime",
]);
// Maps Intl.NumberFormat part types to ValuePart types for monetary states.
const MONETARY_TYPE_MAP: Record<string, ValuePart["type"]> = {
integer: "value",
group: "value",
decimal: "value",
fraction: "value",
minusSign: "value",
plusSign: "value",
literal: "literal",
currency: "unit",
};
export const computeStateDisplay = (
localize: LocalizeFunc,
stateObj: HassEntity,
@@ -138,21 +172,10 @@ const computeStateToPartsFromEntityAttributes = (
}
if (parts.length) {
const TYPE_MAP: Record<string, ValuePart["type"]> = {
integer: "value",
group: "value",
decimal: "value",
fraction: "value",
minusSign: "value",
plusSign: "value",
literal: "literal",
currency: "unit",
};
const valueParts: ValuePart[] = [];
for (const part of parts) {
const type = TYPE_MAP[part.type];
const type = MONETARY_TYPE_MAP[part.type];
if (!type) continue;
const last = valueParts[valueParts.length - 1];
// Merge consecutive value parts (e.g. "-" + "12" + "." + "00" → "-12.00")
@@ -191,7 +214,7 @@ const computeStateToPartsFromEntityAttributes = (
return [{ type: "value", value: value }];
}
if (["date", "input_datetime", "time"].includes(domain)) {
if (DATE_TIME_DOMAINS.has(domain)) {
// If trying to display an explicit state, need to parse the explicit state to `Date` then format.
// Attributes aren't available, we have to use `state`.
@@ -250,23 +273,7 @@ const computeStateToPartsFromEntityAttributes = (
// state is a timestamp
if (
[
"ai_task",
"button",
"conversation",
"event",
"image",
"infrared",
"input_button",
"notify",
"radio_frequency",
"scene",
"stt",
"tag",
"tts",
"wake_word",
"datetime",
].includes(domain) ||
TIMESTAMP_DOMAINS.has(domain) ||
(domain === "sensor" &&
SENSOR_TIMESTAMP_DEVICE_CLASSES.includes(attributes.device_class))
) {
+21 -2
View File
@@ -40,6 +40,25 @@ export const numberFormatToLocale = (
}
};
// Constructing an Intl.NumberFormat is comparatively expensive, and these
// formatters are created on every numeric state render. The number of distinct
// (locale, options) combinations is small and bounded in practice, so cache the
// instances instead of rebuilding them on every call.
const numberFormatCache = new Map<string, Intl.NumberFormat>();
const getNumberFormatter = (
locale: string | string[] | undefined,
options: Intl.NumberFormatOptions
): Intl.NumberFormat => {
const key = JSON.stringify([locale, options]);
let formatter = numberFormatCache.get(key);
if (!formatter) {
formatter = new Intl.NumberFormat(locale, options);
numberFormatCache.set(key, formatter);
}
return formatter;
};
/**
* Formats a number based on the user's preference with thousands separator(s) and decimal character for better legibility.
*
@@ -75,7 +94,7 @@ export const formatNumberToParts = (
localeOptions?.number_format !== NumberFormat.none &&
!Number.isNaN(Number(num))
) {
return new Intl.NumberFormat(
return getNumberFormatter(
locale,
getDefaultFormatOptions(num, options)
).formatToParts(Number(num));
@@ -87,7 +106,7 @@ export const formatNumberToParts = (
localeOptions?.number_format === NumberFormat.none
) {
// If NumberFormat is none, use en-US format without grouping.
return new Intl.NumberFormat(
return getNumberFormatter(
"en-US",
getDefaultFormatOptions(num, {
...options,
+8 -2
View File
@@ -215,10 +215,16 @@ export class HaDataTable extends LitElement {
if (clear) {
this._checkedRows = [];
}
// Map + Set keep a large selection O(rows + ids) instead of O(rows × ids).
const rowLookup = new Map(
(this._filteredData || []).map((data) => [data[this.id], data])
);
const checkedRows = new Set(this._checkedRows);
ids.forEach((id) => {
const row = this._filteredData?.find((data) => data[this.id] === id);
if (row?.selectable !== false && !this._checkedRows.includes(id)) {
const row = rowLookup.get(id);
if (row?.selectable !== false && !checkedRows.has(id)) {
this._checkedRows.push(id);
checkedRows.add(id);
}
});
this._lastSelectedRowId = null;
+16 -6
View File
@@ -85,15 +85,25 @@ export class HaTTSVoicePicker extends LitElement {
await listTTSVoices(this.hass, this.engineId, this.language)
).voices;
if (!this.value) {
const valueIsValid =
this.value &&
this._voices?.some((voice) => voice.voice_id === this.value);
if (valueIsValid) {
return;
}
if (
!this._voices ||
!this._voices.find((voice) => voice.voice_id === this.value)
) {
this.value = undefined;
// The current value is missing or no longer valid for the loaded voices.
// When a voice is required, auto-select the first one (the <ha-select>
// already displays it) so the value is propagated to the parent;
// otherwise clear it.
const newValue =
this.required && this._voices?.length
? this._voices[0].voice_id
: undefined;
if (newValue !== this.value) {
this.value = newValue;
fireEvent(this, "value-changed", { value: this.value });
}
}
@@ -261,15 +261,22 @@ export class HaConfigAppsInstalled extends LitElement {
}
.search {
display: flex;
align-items: center;
width: 100%;
height: 56px;
position: sticky;
top: 0;
z-index: 2;
background-color: var(--primary-background-color);
padding: 0 var(--ha-space-4);
box-sizing: border-box;
border-bottom: 1px solid var(--divider-color);
}
ha-input-search {
padding: var(--ha-space-3) var(--ha-space-2);
background: var(--sidebar-background-color);
border-bottom: 1px solid var(--divider-color);
flex: 1;
min-width: 0;
}
.content {
@@ -1178,9 +1178,17 @@ export class HaConfigEntities extends LitElement {
return;
}
// Only the *set* of entity ids matters for the list below. A plain state
// value change on an existing entity cannot add an "entity without unique
// id", so detecting a newly added entity lets us skip the (potentially
// large) rebuild on every state update, which fires constantly.
const stateEntityAdded =
changedProps.has("hass") &&
(!oldHass ||
Object.keys(this.hass.states).some((id) => !(id in oldHass.states)));
if (
(changedProps.has("hass") &&
(!oldHass || oldHass.states !== this.hass.states)) ||
stateEntityAdded ||
changedProps.has("_entities") ||
changedProps.has("_entitySources") ||
changedProps.has("_exposedEntities")
@@ -1047,7 +1047,7 @@ export class HuiTodoListCard extends LitElement implements LovelaceCard {
cursor: move; /* fallback if grab cursor is unsupported */
cursor: grab;
height: 24px;
padding: 16px 4px;
padding: 0 4px;
}
.deleteItemButton {
+3 -3
View File
@@ -5327,9 +5327,9 @@
"type_input": "Numeric value of another entity",
"description": {
"picker": "Triggers when the numeric value of an entity''s state (or attribute''s value) crosses a given threshold.",
"above": "When {attribute, select, \n undefined {} \n other {{attribute} from }\n }{entity} {numberOfEntities, plural,\n one {is}\n other {are}\n} above {above}{duration, select, \n undefined {} \n other { for {duration}}\n }",
"below": "When {attribute, select, \n undefined {} \n other {{attribute} from }\n }{entity} {numberOfEntities, plural,\n one {is}\n other {are}\n} below {below}{duration, select, \n undefined {} \n other { for {duration}}\n }",
"above-below": "When {attribute, select, \n undefined {} \n other {{attribute} from }\n }{entity} {numberOfEntities, plural,\n one {is}\n other {are}\n} above {above} and below {below}{duration, select, \n undefined {} \n other { for {duration}}\n }"
"above": "When {attribute, select, \n undefined {} \n other {{attribute} from }\n }{entity} {numberOfEntities, plural,\n one {is}\n other {is}\n} above {above}{duration, select, \n undefined {} \n other { for {duration}}\n }",
"below": "When {attribute, select, \n undefined {} \n other {{attribute} from }\n }{entity} {numberOfEntities, plural,\n one {is}\n other {is}\n} below {below}{duration, select, \n undefined {} \n other { for {duration}}\n }",
"above-below": "When {attribute, select, \n undefined {} \n other {{attribute} from }\n }{entity} {numberOfEntities, plural,\n one {is}\n other {is}\n} above {above} and below {below}{duration, select, \n undefined {} \n other { for {duration}}\n }"
}
},
"persistent_notification": {
+20
View File
@@ -64,6 +64,26 @@ describe("formatNumber", () => {
assert.strictEqual(formatNumber("", defaultLocale), "0");
});
it("Returns consistent results for interleaved calls with different options (formatter cache)", () => {
// Exercises the cached Intl.NumberFormat instances: alternating option
// shapes must each keep producing their own correct output.
for (let i = 0; i < 3; i++) {
assert.strictEqual(formatNumber(1234.5, defaultLocale), "1,234.5");
assert.strictEqual(
formatNumber(1234.5, defaultLocale, { minimumFractionDigits: 2 }),
"1,234.50"
);
assert.strictEqual(formatNumber("1234.50", defaultLocale), "1,234.50");
assert.strictEqual(
formatNumber(1234.5, {
...defaultLocale,
number_format: NumberFormat.none,
}),
"1234.5"
);
}
});
it("Formats number with options", () => {
assert.strictEqual(
formatNumber(1234.5, defaultLocale, {
+50 -50
View File
@@ -3591,51 +3591,51 @@ __metadata:
languageName: node
linkType: hard
"@rspack/binding-darwin-arm64@npm:2.0.6":
version: 2.0.6
resolution: "@rspack/binding-darwin-arm64@npm:2.0.6"
"@rspack/binding-darwin-arm64@npm:2.0.8":
version: 2.0.8
resolution: "@rspack/binding-darwin-arm64@npm:2.0.8"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard
"@rspack/binding-darwin-x64@npm:2.0.6":
version: 2.0.6
resolution: "@rspack/binding-darwin-x64@npm:2.0.6"
"@rspack/binding-darwin-x64@npm:2.0.8":
version: 2.0.8
resolution: "@rspack/binding-darwin-x64@npm:2.0.8"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard
"@rspack/binding-linux-arm64-gnu@npm:2.0.6":
version: 2.0.6
resolution: "@rspack/binding-linux-arm64-gnu@npm:2.0.6"
"@rspack/binding-linux-arm64-gnu@npm:2.0.8":
version: 2.0.8
resolution: "@rspack/binding-linux-arm64-gnu@npm:2.0.8"
conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node
linkType: hard
"@rspack/binding-linux-arm64-musl@npm:2.0.6":
version: 2.0.6
resolution: "@rspack/binding-linux-arm64-musl@npm:2.0.6"
"@rspack/binding-linux-arm64-musl@npm:2.0.8":
version: 2.0.8
resolution: "@rspack/binding-linux-arm64-musl@npm:2.0.8"
conditions: os=linux & cpu=arm64 & libc=musl
languageName: node
linkType: hard
"@rspack/binding-linux-x64-gnu@npm:2.0.6":
version: 2.0.6
resolution: "@rspack/binding-linux-x64-gnu@npm:2.0.6"
"@rspack/binding-linux-x64-gnu@npm:2.0.8":
version: 2.0.8
resolution: "@rspack/binding-linux-x64-gnu@npm:2.0.8"
conditions: os=linux & cpu=x64 & libc=glibc
languageName: node
linkType: hard
"@rspack/binding-linux-x64-musl@npm:2.0.6":
version: 2.0.6
resolution: "@rspack/binding-linux-x64-musl@npm:2.0.6"
"@rspack/binding-linux-x64-musl@npm:2.0.8":
version: 2.0.8
resolution: "@rspack/binding-linux-x64-musl@npm:2.0.8"
conditions: os=linux & cpu=x64 & libc=musl
languageName: node
linkType: hard
"@rspack/binding-wasm32-wasi@npm:2.0.6":
version: 2.0.6
resolution: "@rspack/binding-wasm32-wasi@npm:2.0.6"
"@rspack/binding-wasm32-wasi@npm:2.0.8":
version: 2.0.8
resolution: "@rspack/binding-wasm32-wasi@npm:2.0.8"
dependencies:
"@emnapi/core": "npm:1.10.0"
"@emnapi/runtime": "npm:1.10.0"
@@ -3644,41 +3644,41 @@ __metadata:
languageName: node
linkType: hard
"@rspack/binding-win32-arm64-msvc@npm:2.0.6":
version: 2.0.6
resolution: "@rspack/binding-win32-arm64-msvc@npm:2.0.6"
"@rspack/binding-win32-arm64-msvc@npm:2.0.8":
version: 2.0.8
resolution: "@rspack/binding-win32-arm64-msvc@npm:2.0.8"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard
"@rspack/binding-win32-ia32-msvc@npm:2.0.6":
version: 2.0.6
resolution: "@rspack/binding-win32-ia32-msvc@npm:2.0.6"
"@rspack/binding-win32-ia32-msvc@npm:2.0.8":
version: 2.0.8
resolution: "@rspack/binding-win32-ia32-msvc@npm:2.0.8"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard
"@rspack/binding-win32-x64-msvc@npm:2.0.6":
version: 2.0.6
resolution: "@rspack/binding-win32-x64-msvc@npm:2.0.6"
"@rspack/binding-win32-x64-msvc@npm:2.0.8":
version: 2.0.8
resolution: "@rspack/binding-win32-x64-msvc@npm:2.0.8"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard
"@rspack/binding@npm:2.0.6":
version: 2.0.6
resolution: "@rspack/binding@npm:2.0.6"
"@rspack/binding@npm:2.0.8":
version: 2.0.8
resolution: "@rspack/binding@npm:2.0.8"
dependencies:
"@rspack/binding-darwin-arm64": "npm:2.0.6"
"@rspack/binding-darwin-x64": "npm:2.0.6"
"@rspack/binding-linux-arm64-gnu": "npm:2.0.6"
"@rspack/binding-linux-arm64-musl": "npm:2.0.6"
"@rspack/binding-linux-x64-gnu": "npm:2.0.6"
"@rspack/binding-linux-x64-musl": "npm:2.0.6"
"@rspack/binding-wasm32-wasi": "npm:2.0.6"
"@rspack/binding-win32-arm64-msvc": "npm:2.0.6"
"@rspack/binding-win32-ia32-msvc": "npm:2.0.6"
"@rspack/binding-win32-x64-msvc": "npm:2.0.6"
"@rspack/binding-darwin-arm64": "npm:2.0.8"
"@rspack/binding-darwin-x64": "npm:2.0.8"
"@rspack/binding-linux-arm64-gnu": "npm:2.0.8"
"@rspack/binding-linux-arm64-musl": "npm:2.0.8"
"@rspack/binding-linux-x64-gnu": "npm:2.0.8"
"@rspack/binding-linux-x64-musl": "npm:2.0.8"
"@rspack/binding-wasm32-wasi": "npm:2.0.8"
"@rspack/binding-win32-arm64-msvc": "npm:2.0.8"
"@rspack/binding-win32-ia32-msvc": "npm:2.0.8"
"@rspack/binding-win32-x64-msvc": "npm:2.0.8"
dependenciesMeta:
"@rspack/binding-darwin-arm64":
optional: true
@@ -3700,15 +3700,15 @@ __metadata:
optional: true
"@rspack/binding-win32-x64-msvc":
optional: true
checksum: 10/c2e5245abab3257d02f5d98947fad26c8de1b18bb17362734035cfbdd725d9c6c78432372bdff985b32fa4062059d7210e9f5ea7314ae3080805b64f616fe348
checksum: 10/aface75866ff0bcd4934fda26e856e8de63e710a1489e654f1c6e5108d6ca46d2183b01aad2a76db1511e99843522272882ece53c2a4cf9fbfe0ac5ab5bcd5c2
languageName: node
linkType: hard
"@rspack/core@npm:2.0.6":
version: 2.0.6
resolution: "@rspack/core@npm:2.0.6"
"@rspack/core@npm:2.0.8":
version: 2.0.8
resolution: "@rspack/core@npm:2.0.8"
dependencies:
"@rspack/binding": "npm:2.0.6"
"@rspack/binding": "npm:2.0.8"
peerDependencies:
"@module-federation/runtime-tools": ^0.24.1 || ^2.0.0
"@swc/helpers": ^0.5.23
@@ -3717,7 +3717,7 @@ __metadata:
optional: true
"@swc/helpers":
optional: true
checksum: 10/d2417690e8135342179bc9e5035e16fe827522b4c0babef029a21ff5903cd56c09b86f08924527bd7d3e66f178f1f678ce099199cac8c1a137b18c5d8892e613
checksum: 10/93e34b878dbc69c12f9b06909354246597a5c387c5df77f61e56f3a20e2b45434b9fa8734866f4e662ab0e3456064bf8133ae6f58a3afffee5053a27b8395195
languageName: node
linkType: hard
@@ -8483,7 +8483,7 @@ __metadata:
"@octokit/rest": "npm:22.0.1"
"@replit/codemirror-indentation-markers": "npm:6.5.3"
"@rsdoctor/rspack-plugin": "npm:1.5.12"
"@rspack/core": "npm:2.0.6"
"@rspack/core": "npm:2.0.8"
"@rspack/dev-server": "npm:2.0.3"
"@swc/helpers": "npm:0.5.23"
"@thomasloven/round-slider": "npm:0.6.0"