mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-17 14:26:35 +00:00
Add support for "all" as entity ID in action "service" (#7954)
This commit is contained in:
parent
1667973a66
commit
2fdc746392
@ -195,7 +195,7 @@ export default class HaAutomationActionRow extends LitElement {
|
||||
<ul>
|
||||
${this._warnings.map((warning) => html`<li>${warning}</li>`)}
|
||||
</ul>
|
||||
You can still edit your config in yaml.
|
||||
You can still edit your config in YAML.
|
||||
</div>`
|
||||
: ""}
|
||||
${yamlMode
|
||||
|
@ -19,12 +19,12 @@ import type { HaYamlEditor } from "../../../../../components/ha-yaml-editor";
|
||||
import { ServiceAction } from "../../../../../data/script";
|
||||
import type { PolymerChangedEvent } from "../../../../../polymer-types";
|
||||
import type { HomeAssistant } from "../../../../../types";
|
||||
import { EntityId } from "../../../../lovelace/common/structs/is-entity-id";
|
||||
import { EntityIdOrAll } from "../../../../lovelace/common/structs/is-entity-id";
|
||||
import { ActionElement, handleChangeEvent } from "../ha-automation-action-row";
|
||||
|
||||
const actionStruct = object({
|
||||
service: optional(string()),
|
||||
entity_id: optional(EntityId),
|
||||
entity_id: optional(EntityIdOrAll),
|
||||
data: optional(any()),
|
||||
});
|
||||
|
||||
|
@ -7,7 +7,7 @@ const isEntityId = (value: unknown, context: StructContext): StructResult => {
|
||||
if (!value.includes(".")) {
|
||||
return [
|
||||
context.fail({
|
||||
type: "entity id should be in the format 'domain.entity'",
|
||||
type: "Entity ID should be in the format 'domain.entity'",
|
||||
}),
|
||||
];
|
||||
}
|
||||
@ -15,3 +15,16 @@ const isEntityId = (value: unknown, context: StructContext): StructResult => {
|
||||
};
|
||||
|
||||
export const EntityId = struct("entity-id", isEntityId);
|
||||
|
||||
const isEntityIdOrAll = (
|
||||
value: unknown,
|
||||
context: StructContext
|
||||
): StructResult => {
|
||||
if (typeof value === "string" && value === "all") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isEntityId(value, context);
|
||||
};
|
||||
|
||||
export const EntityIdOrAll = struct("entity-id-all", isEntityIdOrAll);
|
||||
|
Loading…
x
Reference in New Issue
Block a user