mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
Add base trigger to struct (#10851)
This commit is contained in:
parent
0c3fd8f3ad
commit
cea40610c0
@ -1,4 +1,9 @@
|
|||||||
import { object, optional, number } from "superstruct";
|
import { object, optional, number, string } from "superstruct";
|
||||||
|
|
||||||
|
export const baseTriggerStruct = object({
|
||||||
|
platform: string(),
|
||||||
|
id: optional(string()),
|
||||||
|
});
|
||||||
|
|
||||||
export const forDictStruct = object({
|
export const forDictStruct = object({
|
||||||
days: optional(number()),
|
days: optional(number()),
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
import "@polymer/paper-input/paper-input";
|
import "@polymer/paper-input/paper-input";
|
||||||
import { html, LitElement, PropertyValues } from "lit";
|
import { html, LitElement, PropertyValues } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { assert, literal, object, optional, string, union } from "superstruct";
|
import {
|
||||||
|
assert,
|
||||||
|
assign,
|
||||||
|
literal,
|
||||||
|
object,
|
||||||
|
optional,
|
||||||
|
string,
|
||||||
|
union,
|
||||||
|
} from "superstruct";
|
||||||
import { createDurationData } from "../../../../../common/datetime/create_duration_data";
|
import { createDurationData } from "../../../../../common/datetime/create_duration_data";
|
||||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||||
import { hasTemplate } from "../../../../../common/string/has-template";
|
import { hasTemplate } from "../../../../../common/string/has-template";
|
||||||
@ -10,20 +18,23 @@ import "../../../../../components/entity/ha-entity-picker";
|
|||||||
import "../../../../../components/ha-duration-input";
|
import "../../../../../components/ha-duration-input";
|
||||||
import { StateTrigger } from "../../../../../data/automation";
|
import { StateTrigger } from "../../../../../data/automation";
|
||||||
import { HomeAssistant } from "../../../../../types";
|
import { HomeAssistant } from "../../../../../types";
|
||||||
import { forDictStruct } from "../../structs";
|
import { baseTriggerStruct, forDictStruct } from "../../structs";
|
||||||
import {
|
import {
|
||||||
handleChangeEvent,
|
handleChangeEvent,
|
||||||
TriggerElement,
|
TriggerElement,
|
||||||
} from "../ha-automation-trigger-row";
|
} from "../ha-automation-trigger-row";
|
||||||
|
|
||||||
const stateTriggerStruct = object({
|
const stateTriggerStruct = assign(
|
||||||
platform: literal("state"),
|
baseTriggerStruct,
|
||||||
entity_id: string(),
|
object({
|
||||||
attribute: optional(string()),
|
platform: literal("state"),
|
||||||
from: optional(string()),
|
entity_id: string(),
|
||||||
to: optional(string()),
|
attribute: optional(string()),
|
||||||
for: optional(union([string(), forDictStruct])),
|
from: optional(string()),
|
||||||
});
|
to: optional(string()),
|
||||||
|
for: optional(union([string(), forDictStruct])),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
@customElement("ha-automation-trigger-state")
|
@customElement("ha-automation-trigger-state")
|
||||||
export class HaStateTrigger extends LitElement implements TriggerElement {
|
export class HaStateTrigger extends LitElement implements TriggerElement {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user