fix: Match state trigger/condition semantics to HA (#2565)

* Closes #2530
This commit is contained in:
Dermot Duffy
2026-07-04 10:23:51 -07:00
committed by GitHub
parent 3494706225
commit 9f956fe89f
15 changed files with 825 additions and 69 deletions
+14 -1
View File
@@ -42,7 +42,10 @@ export function arrayMove(target: unknown[], from: number, to: number): unknown[
}
/**
* Convert a value to an array if it is not already one.
* Convert a value to an array if it is not already one, dropping falsy inputs
* (`undefined`/`null`/`0`/`false`/`''`) to an empty array. Use when an absent or
* empty value should become `[]`; use `arrayifyWithFalsy` when falsy values are
* significant and must be preserved.
* @param value: A value (which may be an array).
* @returns An array.
*/
@@ -50,6 +53,16 @@ export const arrayify = <T>(value?: T | T[]): T[] => {
return value ? (Array.isArray(value) ? value : [value]) : [];
};
/**
* Wrap a value in an array if it is not already one, preserving the value --
* including falsy ones like `0`, `false`, `''` and `null`. Contrast with
* `arrayify`, which instead drops all falsy inputs to `[]`.
* @param value A value (which may be an array).
* @returns An array.
*/
export const arrayifyWithFalsy = <T>(value: T | T[]): T[] =>
Array.isArray(value) ? value : [value];
/**
* Convert a value to an set if it is not already one.
* @param value: A value (which may be a set, an array or a T)