Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
});

Expand Down
15 changes: 14 additions & 1 deletion src/panels/lovelace/common/structs/is-entity-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,24 @@ 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'",
}),
];
}
return true;
};

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);