From 20dff9d25d05abd192a4e4433e3de87045dcb21c Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Mon, 5 Dec 2022 15:33:41 +0100 Subject: [PATCH] Fix YAML validation for automation action service call enabling/disabling (#14536) fixes undefined --- .../action/types/ha-automation-action-service.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/panels/config/automation/action/types/ha-automation-action-service.ts b/src/panels/config/automation/action/types/ha-automation-action-service.ts index 83102c1d82..e59c1800dd 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-service.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-service.ts @@ -1,22 +1,13 @@ import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit"; import { customElement, property, state } from "lit/decorators"; -import { any, assert, object, optional, string } from "superstruct"; +import { assert } from "superstruct"; import { fireEvent } from "../../../../../common/dom/fire_event"; import { hasTemplate } from "../../../../../common/string/has-template"; -import { entityIdOrAll } from "../../../../../common/structs/is-entity-id"; import "../../../../../components/ha-service-control"; -import { ServiceAction } from "../../../../../data/script"; +import { ServiceAction, serviceActionStruct } from "../../../../../data/script"; import type { HomeAssistant } from "../../../../../types"; import { ActionElement } from "../ha-automation-action-row"; -const actionStruct = object({ - alias: optional(string()), - service: optional(string()), - entity_id: optional(entityIdOrAll()), - target: optional(any()), - data: optional(any()), -}); - @customElement("ha-automation-action-service") export class HaServiceAction extends LitElement implements ActionElement { @property({ attribute: false }) public hass!: HomeAssistant; @@ -38,7 +29,7 @@ export class HaServiceAction extends LitElement implements ActionElement { return; } try { - assert(this.action, actionStruct); + assert(this.action, serviceActionStruct); } catch (err: any) { fireEvent(this, "ui-mode-not-available", err); return;