mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-18 06:46: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>
|
<ul>
|
||||||
${this._warnings.map((warning) => html`<li>${warning}</li>`)}
|
${this._warnings.map((warning) => html`<li>${warning}</li>`)}
|
||||||
</ul>
|
</ul>
|
||||||
You can still edit your config in yaml.
|
You can still edit your config in YAML.
|
||||||
</div>`
|
</div>`
|
||||||
: ""}
|
: ""}
|
||||||
${yamlMode
|
${yamlMode
|
||||||
|
@ -19,12 +19,12 @@ import type { HaYamlEditor } from "../../../../../components/ha-yaml-editor";
|
|||||||
import { ServiceAction } from "../../../../../data/script";
|
import { ServiceAction } from "../../../../../data/script";
|
||||||
import type { PolymerChangedEvent } from "../../../../../polymer-types";
|
import type { PolymerChangedEvent } from "../../../../../polymer-types";
|
||||||
import type { HomeAssistant } from "../../../../../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";
|
import { ActionElement, handleChangeEvent } from "../ha-automation-action-row";
|
||||||
|
|
||||||
const actionStruct = object({
|
const actionStruct = object({
|
||||||
service: optional(string()),
|
service: optional(string()),
|
||||||
entity_id: optional(EntityId),
|
entity_id: optional(EntityIdOrAll),
|
||||||
data: optional(any()),
|
data: optional(any()),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ const isEntityId = (value: unknown, context: StructContext): StructResult => {
|
|||||||
if (!value.includes(".")) {
|
if (!value.includes(".")) {
|
||||||
return [
|
return [
|
||||||
context.fail({
|
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);
|
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