Add default config automation typings (#21657)

* typings

* fixes

* fixes

* Update more typings
This commit is contained in:
Simon Lamon 2024-08-29 09:55:23 +02:00 committed by GitHub
parent 4913932c97
commit 2df097cd1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
46 changed files with 137 additions and 108 deletions

View File

@ -11,7 +11,6 @@ import { mockHassioSupervisor } from "../../../../demo/src/stubs/hassio_supervis
import type { ConditionWithShorthand } from "../../../../src/data/automation"; import type { ConditionWithShorthand } from "../../../../src/data/automation";
import "../../../../src/panels/config/automation/condition/ha-automation-condition"; import "../../../../src/panels/config/automation/condition/ha-automation-condition";
import { HaDeviceCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-device"; import { HaDeviceCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-device";
import { HaLogicalCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-logical";
import HaNumericStateCondition from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-numeric_state"; import HaNumericStateCondition from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-numeric_state";
import { HaStateCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-state"; import { HaStateCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-state";
import { HaSunCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-sun"; import { HaSunCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-sun";
@ -19,62 +18,67 @@ import { HaTemplateCondition } from "../../../../src/panels/config/automation/co
import { HaTimeCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-time"; import { HaTimeCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-time";
import { HaTriggerCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-trigger"; import { HaTriggerCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-trigger";
import { HaZoneCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-zone"; import { HaZoneCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-zone";
import { HaAndCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-and";
import { HaOrCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-or";
import { HaNotCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-not";
const SCHEMAS: { name: string; conditions: ConditionWithShorthand[] }[] = [ const SCHEMAS: { name: string; conditions: ConditionWithShorthand[] }[] = [
{ {
name: "State", name: "State",
conditions: [{ condition: "state", ...HaStateCondition.defaultConfig }], conditions: [{ ...HaStateCondition.defaultConfig }],
}, },
{ {
name: "Numeric State", name: "Numeric State",
conditions: [ conditions: [{ ...HaNumericStateCondition.defaultConfig }],
{ condition: "numeric_state", ...HaNumericStateCondition.defaultConfig },
],
}, },
{ {
name: "Sun", name: "Sun",
conditions: [{ condition: "sun", ...HaSunCondition.defaultConfig }], conditions: [{ ...HaSunCondition.defaultConfig }],
}, },
{ {
name: "Zone", name: "Zone",
conditions: [{ condition: "zone", ...HaZoneCondition.defaultConfig }], conditions: [{ ...HaZoneCondition.defaultConfig }],
}, },
{ {
name: "Time", name: "Time",
conditions: [{ condition: "time", ...HaTimeCondition.defaultConfig }], conditions: [{ ...HaTimeCondition.defaultConfig }],
}, },
{ {
name: "Template", name: "Template",
conditions: [ conditions: [{ ...HaTemplateCondition.defaultConfig }],
{ condition: "template", ...HaTemplateCondition.defaultConfig },
],
}, },
{ {
name: "Device", name: "Device",
conditions: [{ condition: "device", ...HaDeviceCondition.defaultConfig }], conditions: [{ ...HaDeviceCondition.defaultConfig }],
}, },
{ {
name: "And", name: "And",
conditions: [{ condition: "and", ...HaLogicalCondition.defaultConfig }], conditions: [{ ...HaAndCondition.defaultConfig }],
}, },
{ {
name: "Or", name: "Or",
conditions: [{ condition: "or", ...HaLogicalCondition.defaultConfig }], conditions: [{ ...HaOrCondition.defaultConfig }],
}, },
{ {
name: "Not", name: "Not",
conditions: [{ condition: "not", ...HaLogicalCondition.defaultConfig }], conditions: [{ ...HaNotCondition.defaultConfig }],
}, },
{ {
name: "Trigger", name: "Trigger",
conditions: [{ condition: "trigger", ...HaTriggerCondition.defaultConfig }], conditions: [{ ...HaTriggerCondition.defaultConfig }],
}, },
{ {
name: "Shorthand", name: "Shorthand",
conditions: [ conditions: [
{ and: HaLogicalCondition.defaultConfig.conditions }, {
{ or: HaLogicalCondition.defaultConfig.conditions }, ...HaAndCondition.defaultConfig,
{ not: HaLogicalCondition.defaultConfig.conditions }, },
{
...HaOrCondition.defaultConfig,
},
{
...HaNotCondition.defaultConfig,
},
], ],
}, },
]; ];

View File

@ -30,55 +30,48 @@ import { HaConversationTrigger } from "../../../../src/panels/config/automation/
const SCHEMAS: { name: string; triggers: Trigger[] }[] = [ const SCHEMAS: { name: string; triggers: Trigger[] }[] = [
{ {
name: "State", name: "State",
triggers: [{ platform: "state", ...HaStateTrigger.defaultConfig }], triggers: [{ ...HaStateTrigger.defaultConfig }],
}, },
{ {
name: "MQTT", name: "MQTT",
triggers: [{ platform: "mqtt", ...HaMQTTTrigger.defaultConfig }], triggers: [{ ...HaMQTTTrigger.defaultConfig }],
}, },
{ {
name: "GeoLocation", name: "GeoLocation",
triggers: [ triggers: [{ ...HaGeolocationTrigger.defaultConfig }],
{ platform: "geo_location", ...HaGeolocationTrigger.defaultConfig },
],
}, },
{ {
name: "Home Assistant", name: "Home Assistant",
triggers: [{ platform: "homeassistant", ...HaHassTrigger.defaultConfig }], triggers: [{ ...HaHassTrigger.defaultConfig }],
}, },
{ {
name: "Numeric State", name: "Numeric State",
triggers: [ triggers: [{ ...HaNumericStateTrigger.defaultConfig }],
{ platform: "numeric_state", ...HaNumericStateTrigger.defaultConfig },
],
}, },
{ {
name: "Sun", name: "Sun",
triggers: [{ platform: "sun", ...HaSunTrigger.defaultConfig }], triggers: [{ ...HaSunTrigger.defaultConfig }],
}, },
{ {
name: "Time Pattern", name: "Time Pattern",
triggers: [ triggers: [{ ...HaTimePatternTrigger.defaultConfig }],
{ platform: "time_pattern", ...HaTimePatternTrigger.defaultConfig },
],
}, },
{ {
name: "Webhook", name: "Webhook",
triggers: [{ platform: "webhook", ...HaWebhookTrigger.defaultConfig }], triggers: [{ ...HaWebhookTrigger.defaultConfig }],
}, },
{ {
name: "Persistent Notification", name: "Persistent Notification",
triggers: [ triggers: [
{ {
platform: "persistent_notification",
...HaPersistentNotificationTrigger.defaultConfig, ...HaPersistentNotificationTrigger.defaultConfig,
}, },
], ],
@ -86,37 +79,37 @@ const SCHEMAS: { name: string; triggers: Trigger[] }[] = [
{ {
name: "Zone", name: "Zone",
triggers: [{ platform: "zone", ...HaZoneTrigger.defaultConfig }], triggers: [{ ...HaZoneTrigger.defaultConfig }],
}, },
{ {
name: "Tag", name: "Tag",
triggers: [{ platform: "tag", ...HaTagTrigger.defaultConfig }], triggers: [{ ...HaTagTrigger.defaultConfig }],
}, },
{ {
name: "Time", name: "Time",
triggers: [{ platform: "time", ...HaTimeTrigger.defaultConfig }], triggers: [{ ...HaTimeTrigger.defaultConfig }],
}, },
{ {
name: "Template", name: "Template",
triggers: [{ platform: "template", ...HaTemplateTrigger.defaultConfig }], triggers: [{ ...HaTemplateTrigger.defaultConfig }],
}, },
{ {
name: "Event", name: "Event",
triggers: [{ platform: "event", ...HaEventTrigger.defaultConfig }], triggers: [{ ...HaEventTrigger.defaultConfig }],
}, },
{ {
name: "Device Trigger", name: "Device Trigger",
triggers: [{ platform: "device", ...HaDeviceTrigger.defaultConfig }], triggers: [{ ...HaDeviceTrigger.defaultConfig }],
}, },
{ {
name: "Sentence", name: "Sentence",
triggers: [ triggers: [
{ platform: "conversation", ...HaConversationTrigger.defaultConfig }, { ...HaConversationTrigger.defaultConfig },
{ {
platform: "conversation", platform: "conversation",
command: ["Turn on the lights", "Turn the lights on"], command: ["Turn on the lights", "Turn the lights on"],

View File

@ -86,7 +86,7 @@ export class HaChooseAction extends LitElement implements ActionElement {
this._unsubMql = undefined; this._unsubMql = undefined;
} }
public static get defaultConfig() { public static get defaultConfig(): ChooseAction {
return { choose: [{ conditions: [], sequence: [] }] }; return { choose: [{ conditions: [], sequence: [] }] };
} }

View File

@ -20,7 +20,7 @@ export class HaConditionAction extends LitElement implements ActionElement {
@property({ attribute: false }) public action!: Condition; @property({ attribute: false }) public action!: Condition;
public static get defaultConfig() { public static get defaultConfig(): Omit<Condition, "state" | "entity_id"> {
return { condition: "state" }; return { condition: "state" };
} }
@ -87,13 +87,12 @@ export class HaConditionAction extends LitElement implements ActionElement {
const elClass = customElements.get( const elClass = customElements.get(
`ha-automation-condition-${type}` `ha-automation-condition-${type}`
) as CustomElementConstructor & { ) as CustomElementConstructor & {
defaultConfig: Omit<Condition, "condition">; defaultConfig: Condition;
}; };
if (type !== this.action.condition) { if (type !== this.action.condition) {
fireEvent(this, "value-changed", { fireEvent(this, "value-changed", {
value: { value: {
condition: type,
...elClass.defaultConfig, ...elClass.defaultConfig,
}, },
}); });

View File

@ -19,7 +19,7 @@ export class HaDelayAction extends LitElement implements ActionElement {
@state() private _timeData?: HaDurationData; @state() private _timeData?: HaDurationData;
public static get defaultConfig() { public static get defaultConfig(): DelayAction {
return { delay: "" }; return { delay: "" };
} }

View File

@ -36,7 +36,7 @@ export class HaDeviceAction extends LitElement {
private _origAction?: DeviceAction; private _origAction?: DeviceAction;
public static get defaultConfig() { public static get defaultConfig(): DeviceAction {
return { return {
device_id: "", device_id: "",
domain: "", domain: "",

View File

@ -21,7 +21,7 @@ export class HaIfAction extends LitElement implements ActionElement {
@state() private _showElse = false; @state() private _showElse = false;
public static get defaultConfig() { public static get defaultConfig(): IfAction {
return { return {
if: [], if: [],
then: [], then: [],

View File

@ -18,7 +18,7 @@ export class HaParallelAction extends LitElement implements ActionElement {
@property({ attribute: false }) public action!: ParallelAction; @property({ attribute: false }) public action!: ParallelAction;
public static get defaultConfig() { public static get defaultConfig(): ParallelAction {
return { return {
parallel: [], parallel: [],
}; };

View File

@ -31,7 +31,7 @@ export class HaRepeatAction extends LitElement implements ActionElement {
@property({ type: Array }) public path?: ItemPath; @property({ type: Array }) public path?: ItemPath;
public static get defaultConfig() { public static get defaultConfig(): RepeatAction {
return { repeat: { count: 2, sequence: [] } }; return { repeat: { count: 2, sequence: [] } };
} }

View File

@ -19,7 +19,7 @@ export class HaSequenceAction extends LitElement implements ActionElement {
@property({ attribute: false }) public action!: SequenceAction; @property({ attribute: false }) public action!: SequenceAction;
public static get defaultConfig() { public static get defaultConfig(): SequenceAction {
return { return {
sequence: [], sequence: [],
}; };

View File

@ -52,7 +52,7 @@ export class HaServiceAction extends LitElement implements ActionElement {
} }
); );
public static get defaultConfig() { public static get defaultConfig(): ServiceAction {
return { action: "", data: {} }; return { action: "", data: {} };
} }

View File

@ -25,7 +25,7 @@ export class HaSetConversationResponseAction
@property({ type: Boolean }) public disabled = false; @property({ type: Boolean }) public disabled = false;
public static get defaultConfig() { public static get defaultConfig(): SetConversationResponseAction {
return { set_conversation_response: "" }; return { set_conversation_response: "" };
} }

View File

@ -14,7 +14,7 @@ export class HaStopAction extends LitElement implements ActionElement {
@property({ type: Boolean }) public disabled = false; @property({ type: Boolean }) public disabled = false;
public static get defaultConfig() { public static get defaultConfig(): StopAction {
return { stop: "" }; return { stop: "" };
} }

View File

@ -25,7 +25,7 @@ export class HaWaitForTriggerAction
@property({ attribute: false }) public path?: ItemPath; @property({ attribute: false }) public path?: ItemPath;
public static get defaultConfig() { public static get defaultConfig(): WaitForTriggerAction {
return { wait_for_trigger: [] }; return { wait_for_trigger: [] };
} }

View File

@ -34,7 +34,7 @@ export class HaWaitAction extends LitElement implements ActionElement {
@property({ type: Boolean }) public disabled = false; @property({ type: Boolean }) public disabled = false;
public static get defaultConfig() { public static get defaultConfig(): WaitAction {
return { wait_template: "", continue_on_timeout: true }; return { wait_template: "", continue_on_timeout: true };
} }

View File

@ -207,10 +207,9 @@ export default class HaAutomationCondition extends LitElement {
const elClass = customElements.get( const elClass = customElements.get(
`ha-automation-condition-${condition}` `ha-automation-condition-${condition}`
) as CustomElementConstructor & { ) as CustomElementConstructor & {
defaultConfig: Omit<Condition, "condition">; defaultConfig: Condition;
}; };
conditions = this.conditions.concat({ conditions = this.conditions.concat({
condition: condition as any,
...elClass.defaultConfig, ...elClass.defaultConfig,
}); });
} }

View File

@ -1,8 +1,16 @@
import { customElement } from "lit/decorators"; import { customElement } from "lit/decorators";
import { HaLogicalCondition } from "./ha-automation-condition-logical"; import { HaLogicalCondition } from "./ha-automation-condition-logical";
import { LogicalCondition } from "../../../../../data/automation";
@customElement("ha-automation-condition-and") @customElement("ha-automation-condition-and")
export class HaAndCondition extends HaLogicalCondition {} export class HaAndCondition extends HaLogicalCondition {
public static get defaultConfig(): LogicalCondition {
return {
condition: "and",
conditions: [],
};
}
}
declare global { declare global {
interface HTMLElementTagNameMap { interface HTMLElementTagNameMap {

View File

@ -36,8 +36,9 @@ export class HaDeviceCondition extends LitElement {
private _origCondition?: DeviceCondition; private _origCondition?: DeviceCondition;
public static get defaultConfig() { public static get defaultConfig(): DeviceCondition {
return { return {
condition: "device",
device_id: "", device_id: "",
domain: "", domain: "",
entity_id: "", entity_id: "",

View File

@ -7,7 +7,10 @@ import "../ha-automation-condition";
import type { ConditionElement } from "../ha-automation-condition-row"; import type { ConditionElement } from "../ha-automation-condition-row";
@customElement("ha-automation-condition-logical") @customElement("ha-automation-condition-logical")
export class HaLogicalCondition extends LitElement implements ConditionElement { export abstract class HaLogicalCondition
extends LitElement
implements ConditionElement
{
@property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public hass!: HomeAssistant;
@property({ attribute: false }) public condition!: LogicalCondition; @property({ attribute: false }) public condition!: LogicalCondition;
@ -16,12 +19,6 @@ export class HaLogicalCondition extends LitElement implements ConditionElement {
@property({ attribute: false }) public path?: ItemPath; @property({ attribute: false }) public path?: ItemPath;
public static get defaultConfig() {
return {
conditions: [],
};
}
protected render() { protected render() {
return html` return html`
<ha-automation-condition <ha-automation-condition

View File

@ -1,8 +1,16 @@
import { customElement } from "lit/decorators"; import { customElement } from "lit/decorators";
import { HaLogicalCondition } from "./ha-automation-condition-logical"; import { HaLogicalCondition } from "./ha-automation-condition-logical";
import { LogicalCondition } from "../../../../../data/automation";
@customElement("ha-automation-condition-not") @customElement("ha-automation-condition-not")
export class HaNotCondition extends HaLogicalCondition {} export class HaNotCondition extends HaLogicalCondition {
public static get defaultConfig(): LogicalCondition {
return {
condition: "not",
conditions: [],
};
}
}
declare global { declare global {
interface HTMLElementTagNameMap { interface HTMLElementTagNameMap {

View File

@ -20,8 +20,9 @@ export default class HaNumericStateCondition extends LitElement {
@state() private _inputBelowIsEntity?: boolean; @state() private _inputBelowIsEntity?: boolean;
public static get defaultConfig() { public static get defaultConfig(): NumericStateCondition {
return { return {
condition: "numeric_state",
entity_id: "", entity_id: "",
}; };
} }

View File

@ -1,8 +1,16 @@
import { customElement } from "lit/decorators"; import { customElement } from "lit/decorators";
import { HaLogicalCondition } from "./ha-automation-condition-logical"; import { HaLogicalCondition } from "./ha-automation-condition-logical";
import { LogicalCondition } from "../../../../../data/automation";
@customElement("ha-automation-condition-or") @customElement("ha-automation-condition-or")
export class HaOrCondition extends HaLogicalCondition {} export class HaOrCondition extends HaLogicalCondition {
public static get defaultConfig(): LogicalCondition {
return {
condition: "or",
conditions: [],
};
}
}
declare global { declare global {
interface HTMLElementTagNameMap { interface HTMLElementTagNameMap {

View File

@ -86,8 +86,8 @@ export class HaStateCondition extends LitElement implements ConditionElement {
@property({ type: Boolean }) public disabled = false; @property({ type: Boolean }) public disabled = false;
public static get defaultConfig() { public static get defaultConfig(): StateCondition {
return { entity_id: "", state: "" }; return { condition: "state", entity_id: "", state: "" };
} }
public shouldUpdate(changedProperties: PropertyValues) { public shouldUpdate(changedProperties: PropertyValues) {

View File

@ -17,8 +17,8 @@ export class HaSunCondition extends LitElement implements ConditionElement {
@property({ type: Boolean }) public disabled = false; @property({ type: Boolean }) public disabled = false;
public static get defaultConfig() { public static get defaultConfig(): SunCondition {
return {}; return { condition: "sun" };
} }
private _schema = memoizeOne( private _schema = memoizeOne(

View File

@ -13,8 +13,8 @@ export class HaTemplateCondition extends LitElement {
@property({ type: Boolean }) public disabled = false; @property({ type: Boolean }) public disabled = false;
public static get defaultConfig() { public static get defaultConfig(): TemplateCondition {
return { value_template: "" }; return { condition: "template", value_template: "" };
} }
protected render() { protected render() {

View File

@ -25,8 +25,8 @@ export class HaTimeCondition extends LitElement implements ConditionElement {
@property({ type: Boolean }) public disabled = false; @property({ type: Boolean }) public disabled = false;
public static get defaultConfig() { public static get defaultConfig(): TimeCondition {
return {}; return { condition: "time" };
} }
private _schema = memoizeOne( private _schema = memoizeOne(

View File

@ -27,8 +27,9 @@ export class HaTriggerCondition extends LitElement {
private _unsub?: UnsubscribeFunc; private _unsub?: UnsubscribeFunc;
public static get defaultConfig() { public static get defaultConfig(): TriggerCondition {
return { return {
condition: "trigger",
id: "", id: "",
}; };
} }

View File

@ -21,8 +21,9 @@ export class HaZoneCondition extends LitElement {
@property({ type: Boolean }) public disabled = false; @property({ type: Boolean }) public disabled = false;
public static get defaultConfig() { public static get defaultConfig(): ZoneCondition {
return { return {
condition: "zone",
entity_id: "", entity_id: "",
zone: "", zone: "",
}; };

View File

@ -143,10 +143,9 @@ export default class HaAutomationTrigger extends LitElement {
const elClass = customElements.get( const elClass = customElements.get(
`ha-automation-trigger-${platform}` `ha-automation-trigger-${platform}`
) as CustomElementConstructor & { ) as CustomElementConstructor & {
defaultConfig: Omit<Trigger, "platform">; defaultConfig: Trigger;
}; };
triggers = this.triggers.concat({ triggers = this.triggers.concat({
platform: platform as any,
...elClass.defaultConfig, ...elClass.defaultConfig,
}); });
} }

View File

@ -69,10 +69,12 @@ export class HaCalendarTrigger extends LitElement implements TriggerElement {
] as const ] as const
); );
public static get defaultConfig() { public static get defaultConfig(): CalendarTrigger {
return { return {
platform: "calendar",
entity_id: "",
event: "start" as CalendarTrigger["event"], event: "start" as CalendarTrigger["event"],
offset: 0, offset: "0",
}; };
} }

View File

@ -25,8 +25,8 @@ export class HaConversationTrigger
@query("#option_input", true) private _optionInput?: HaTextField; @query("#option_input", true) private _optionInput?: HaTextField;
public static get defaultConfig(): Omit<ConversationTrigger, "platform"> { public static get defaultConfig(): ConversationTrigger {
return { command: "" }; return { platform: "conversation", command: "" };
} }
protected render() { protected render() {

View File

@ -38,8 +38,9 @@ export class HaDeviceTrigger extends LitElement {
private _origTrigger?: DeviceTrigger; private _origTrigger?: DeviceTrigger;
public static get defaultConfig() { public static get defaultConfig(): DeviceTrigger {
return { return {
platform: "device",
device_id: "", device_id: "",
domain: "", domain: "",
entity_id: "", entity_id: "",

View File

@ -19,8 +19,8 @@ export class HaEventTrigger extends LitElement implements TriggerElement {
@property({ type: Boolean }) public disabled = false; @property({ type: Boolean }) public disabled = false;
public static get defaultConfig() { public static get defaultConfig(): EventTrigger {
return { event_type: "" }; return { platform: "event", event_type: "" };
} }
protected render() { protected render() {

View File

@ -43,8 +43,9 @@ export class HaGeolocationTrigger extends LitElement {
] as const ] as const
); );
public static get defaultConfig() { public static get defaultConfig(): GeoLocationTrigger {
return { return {
platform: "geo_location",
source: "", source: "",
zone: "", zone: "",
event: "enter" as GeoLocationTrigger["event"], event: "enter" as GeoLocationTrigger["event"],

View File

@ -41,8 +41,9 @@ export class HaHassTrigger extends LitElement {
] as const ] as const
); );
public static get defaultConfig() { public static get defaultConfig(): HassTrigger {
return { return {
platform: "homeassistant",
event: "start" as HassTrigger["event"], event: "start" as HassTrigger["event"],
}; };
} }

View File

@ -20,8 +20,8 @@ export class HaMQTTTrigger extends LitElement implements TriggerElement {
@property({ type: Boolean }) public disabled = false; @property({ type: Boolean }) public disabled = false;
public static get defaultConfig() { public static get defaultConfig(): MqttTrigger {
return { topic: "" }; return { platform: "mqtt", topic: "" };
} }
protected render() { protected render() {

View File

@ -237,8 +237,9 @@ export class HaNumericStateTrigger extends LitElement {
} }
} }
public static get defaultConfig() { public static get defaultConfig(): NumericStateTrigger {
return { return {
platform: "numeric_state",
entity_id: [], entity_id: [],
}; };
} }

View File

@ -70,8 +70,9 @@ export class HaPersistentNotificationTrigger
] as const ] as const
); );
public static get defaultConfig() { public static get defaultConfig(): PersistentNotificationTrigger {
return { return {
platform: "persistent_notification",
update_type: [...DEFAULT_UPDATE_TYPES], update_type: [...DEFAULT_UPDATE_TYPES],
notification_id: DEFAULT_NOTIFICATION_ID, notification_id: DEFAULT_NOTIFICATION_ID,
}; };

View File

@ -48,8 +48,8 @@ export class HaStateTrigger extends LitElement implements TriggerElement {
@property({ type: Boolean }) public disabled = false; @property({ type: Boolean }) public disabled = false;
public static get defaultConfig() { public static get defaultConfig(): StateTrigger {
return { entity_id: [] }; return { platform: "state", entity_id: [] };
} }
private _schema = memoizeOne( private _schema = memoizeOne(

View File

@ -43,8 +43,9 @@ export class HaSunTrigger extends LitElement implements TriggerElement {
] as const ] as const
); );
public static get defaultConfig() { public static get defaultConfig(): SunTrigger {
return { return {
platform: "sun",
event: "sunrise" as SunTrigger["event"], event: "sunrise" as SunTrigger["event"],
offset: 0, offset: 0,
}; };

View File

@ -19,8 +19,8 @@ export class HaTagTrigger extends LitElement implements TriggerElement {
@state() private _tags?: Tag[]; @state() private _tags?: Tag[];
public static get defaultConfig() { public static get defaultConfig(): TagTrigger {
return { tag_id: "" }; return { platform: "tag", tag_id: "" };
} }
protected firstUpdated(changedProperties: PropertyValues) { protected firstUpdated(changedProperties: PropertyValues) {

View File

@ -22,8 +22,8 @@ export class HaTemplateTrigger extends LitElement {
@property({ type: Boolean }) public disabled = false; @property({ type: Boolean }) public disabled = false;
public static get defaultConfig() { public static get defaultConfig(): TemplateTrigger {
return { value_template: "" }; return { platform: "template", value_template: "" };
} }
public willUpdate(changedProperties: PropertyValues) { public willUpdate(changedProperties: PropertyValues) {

View File

@ -19,8 +19,8 @@ export class HaTimeTrigger extends LitElement implements TriggerElement {
@state() private _inputMode?: boolean; @state() private _inputMode?: boolean;
public static get defaultConfig() { public static get defaultConfig(): TimeTrigger {
return { at: "" }; return { platform: "time", at: "" };
} }
private _schema = memoizeOne( private _schema = memoizeOne(

View File

@ -21,8 +21,8 @@ export class HaTimePatternTrigger extends LitElement implements TriggerElement {
@property({ type: Boolean }) public disabled = false; @property({ type: Boolean }) public disabled = false;
public static get defaultConfig() { public static get defaultConfig(): TimePatternTrigger {
return {}; return { platform: "time_pattern" };
} }
protected render() { protected render() {

View File

@ -36,8 +36,9 @@ export class HaWebhookTrigger extends LitElement {
private _unsub?: UnsubscribeFunc; private _unsub?: UnsubscribeFunc;
public static get defaultConfig() { public static get defaultConfig(): WebhookTrigger {
return { return {
platform: "webhook",
allowed_methods: [...DEFAULT_METHODS], allowed_methods: [...DEFAULT_METHODS],
local_only: true, local_only: true,
webhook_id: DEFAULT_WEBHOOK_ID, webhook_id: DEFAULT_WEBHOOK_ID,

View File

@ -23,8 +23,9 @@ export class HaZoneTrigger extends LitElement {
@property({ type: Boolean }) public disabled = false; @property({ type: Boolean }) public disabled = false;
public static get defaultConfig() { public static get defaultConfig(): ZoneTrigger {
return { return {
platform: "zone",
entity_id: "", entity_id: "",
zone: "", zone: "",
event: "enter" as ZoneTrigger["event"], event: "enter" as ZoneTrigger["event"],