diff --git a/gallery/src/pages/automation/editor-condition.ts b/gallery/src/pages/automation/editor-condition.ts index ed30c74272..9095461c69 100644 --- a/gallery/src/pages/automation/editor-condition.ts +++ b/gallery/src/pages/automation/editor-condition.ts @@ -11,7 +11,6 @@ import { mockHassioSupervisor } from "../../../../demo/src/stubs/hassio_supervis import type { ConditionWithShorthand } from "../../../../src/data/automation"; import "../../../../src/panels/config/automation/condition/ha-automation-condition"; 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 { 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"; @@ -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 { 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 { 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[] }[] = [ { name: "State", - conditions: [{ condition: "state", ...HaStateCondition.defaultConfig }], + conditions: [{ ...HaStateCondition.defaultConfig }], }, { name: "Numeric State", - conditions: [ - { condition: "numeric_state", ...HaNumericStateCondition.defaultConfig }, - ], + conditions: [{ ...HaNumericStateCondition.defaultConfig }], }, { name: "Sun", - conditions: [{ condition: "sun", ...HaSunCondition.defaultConfig }], + conditions: [{ ...HaSunCondition.defaultConfig }], }, { name: "Zone", - conditions: [{ condition: "zone", ...HaZoneCondition.defaultConfig }], + conditions: [{ ...HaZoneCondition.defaultConfig }], }, { name: "Time", - conditions: [{ condition: "time", ...HaTimeCondition.defaultConfig }], + conditions: [{ ...HaTimeCondition.defaultConfig }], }, { name: "Template", - conditions: [ - { condition: "template", ...HaTemplateCondition.defaultConfig }, - ], + conditions: [{ ...HaTemplateCondition.defaultConfig }], }, { name: "Device", - conditions: [{ condition: "device", ...HaDeviceCondition.defaultConfig }], + conditions: [{ ...HaDeviceCondition.defaultConfig }], }, { name: "And", - conditions: [{ condition: "and", ...HaLogicalCondition.defaultConfig }], + conditions: [{ ...HaAndCondition.defaultConfig }], }, { name: "Or", - conditions: [{ condition: "or", ...HaLogicalCondition.defaultConfig }], + conditions: [{ ...HaOrCondition.defaultConfig }], }, { name: "Not", - conditions: [{ condition: "not", ...HaLogicalCondition.defaultConfig }], + conditions: [{ ...HaNotCondition.defaultConfig }], }, { name: "Trigger", - conditions: [{ condition: "trigger", ...HaTriggerCondition.defaultConfig }], + conditions: [{ ...HaTriggerCondition.defaultConfig }], }, { name: "Shorthand", conditions: [ - { and: HaLogicalCondition.defaultConfig.conditions }, - { or: HaLogicalCondition.defaultConfig.conditions }, - { not: HaLogicalCondition.defaultConfig.conditions }, + { + ...HaAndCondition.defaultConfig, + }, + { + ...HaOrCondition.defaultConfig, + }, + { + ...HaNotCondition.defaultConfig, + }, ], }, ]; diff --git a/gallery/src/pages/automation/editor-trigger.ts b/gallery/src/pages/automation/editor-trigger.ts index 1ed11eb0a8..bb79f63a71 100644 --- a/gallery/src/pages/automation/editor-trigger.ts +++ b/gallery/src/pages/automation/editor-trigger.ts @@ -30,55 +30,48 @@ import { HaConversationTrigger } from "../../../../src/panels/config/automation/ const SCHEMAS: { name: string; triggers: Trigger[] }[] = [ { name: "State", - triggers: [{ platform: "state", ...HaStateTrigger.defaultConfig }], + triggers: [{ ...HaStateTrigger.defaultConfig }], }, { name: "MQTT", - triggers: [{ platform: "mqtt", ...HaMQTTTrigger.defaultConfig }], + triggers: [{ ...HaMQTTTrigger.defaultConfig }], }, { name: "GeoLocation", - triggers: [ - { platform: "geo_location", ...HaGeolocationTrigger.defaultConfig }, - ], + triggers: [{ ...HaGeolocationTrigger.defaultConfig }], }, { name: "Home Assistant", - triggers: [{ platform: "homeassistant", ...HaHassTrigger.defaultConfig }], + triggers: [{ ...HaHassTrigger.defaultConfig }], }, { name: "Numeric State", - triggers: [ - { platform: "numeric_state", ...HaNumericStateTrigger.defaultConfig }, - ], + triggers: [{ ...HaNumericStateTrigger.defaultConfig }], }, { name: "Sun", - triggers: [{ platform: "sun", ...HaSunTrigger.defaultConfig }], + triggers: [{ ...HaSunTrigger.defaultConfig }], }, { name: "Time Pattern", - triggers: [ - { platform: "time_pattern", ...HaTimePatternTrigger.defaultConfig }, - ], + triggers: [{ ...HaTimePatternTrigger.defaultConfig }], }, { name: "Webhook", - triggers: [{ platform: "webhook", ...HaWebhookTrigger.defaultConfig }], + triggers: [{ ...HaWebhookTrigger.defaultConfig }], }, { name: "Persistent Notification", triggers: [ { - platform: "persistent_notification", ...HaPersistentNotificationTrigger.defaultConfig, }, ], @@ -86,37 +79,37 @@ const SCHEMAS: { name: string; triggers: Trigger[] }[] = [ { name: "Zone", - triggers: [{ platform: "zone", ...HaZoneTrigger.defaultConfig }], + triggers: [{ ...HaZoneTrigger.defaultConfig }], }, { name: "Tag", - triggers: [{ platform: "tag", ...HaTagTrigger.defaultConfig }], + triggers: [{ ...HaTagTrigger.defaultConfig }], }, { name: "Time", - triggers: [{ platform: "time", ...HaTimeTrigger.defaultConfig }], + triggers: [{ ...HaTimeTrigger.defaultConfig }], }, { name: "Template", - triggers: [{ platform: "template", ...HaTemplateTrigger.defaultConfig }], + triggers: [{ ...HaTemplateTrigger.defaultConfig }], }, { name: "Event", - triggers: [{ platform: "event", ...HaEventTrigger.defaultConfig }], + triggers: [{ ...HaEventTrigger.defaultConfig }], }, { name: "Device Trigger", - triggers: [{ platform: "device", ...HaDeviceTrigger.defaultConfig }], + triggers: [{ ...HaDeviceTrigger.defaultConfig }], }, { name: "Sentence", triggers: [ - { platform: "conversation", ...HaConversationTrigger.defaultConfig }, + { ...HaConversationTrigger.defaultConfig }, { platform: "conversation", command: ["Turn on the lights", "Turn the lights on"], diff --git a/src/panels/config/automation/action/types/ha-automation-action-choose.ts b/src/panels/config/automation/action/types/ha-automation-action-choose.ts index 3d6dd20ac6..1da1e87d46 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-choose.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-choose.ts @@ -86,7 +86,7 @@ export class HaChooseAction extends LitElement implements ActionElement { this._unsubMql = undefined; } - public static get defaultConfig() { + public static get defaultConfig(): ChooseAction { return { choose: [{ conditions: [], sequence: [] }] }; } diff --git a/src/panels/config/automation/action/types/ha-automation-action-condition.ts b/src/panels/config/automation/action/types/ha-automation-action-condition.ts index 3b098e9a86..9fa89e9c90 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-condition.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-condition.ts @@ -20,7 +20,7 @@ export class HaConditionAction extends LitElement implements ActionElement { @property({ attribute: false }) public action!: Condition; - public static get defaultConfig() { + public static get defaultConfig(): Omit { return { condition: "state" }; } @@ -87,13 +87,12 @@ export class HaConditionAction extends LitElement implements ActionElement { const elClass = customElements.get( `ha-automation-condition-${type}` ) as CustomElementConstructor & { - defaultConfig: Omit; + defaultConfig: Condition; }; if (type !== this.action.condition) { fireEvent(this, "value-changed", { value: { - condition: type, ...elClass.defaultConfig, }, }); diff --git a/src/panels/config/automation/action/types/ha-automation-action-delay.ts b/src/panels/config/automation/action/types/ha-automation-action-delay.ts index c8978e30eb..0a0a2569a7 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-delay.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-delay.ts @@ -19,7 +19,7 @@ export class HaDelayAction extends LitElement implements ActionElement { @state() private _timeData?: HaDurationData; - public static get defaultConfig() { + public static get defaultConfig(): DelayAction { return { delay: "" }; } diff --git a/src/panels/config/automation/action/types/ha-automation-action-device_id.ts b/src/panels/config/automation/action/types/ha-automation-action-device_id.ts index cf5a09d68d..328fd2cfb4 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-device_id.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-device_id.ts @@ -36,7 +36,7 @@ export class HaDeviceAction extends LitElement { private _origAction?: DeviceAction; - public static get defaultConfig() { + public static get defaultConfig(): DeviceAction { return { device_id: "", domain: "", diff --git a/src/panels/config/automation/action/types/ha-automation-action-if.ts b/src/panels/config/automation/action/types/ha-automation-action-if.ts index b68cf1f157..975fb03ec3 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-if.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-if.ts @@ -21,7 +21,7 @@ export class HaIfAction extends LitElement implements ActionElement { @state() private _showElse = false; - public static get defaultConfig() { + public static get defaultConfig(): IfAction { return { if: [], then: [], diff --git a/src/panels/config/automation/action/types/ha-automation-action-parallel.ts b/src/panels/config/automation/action/types/ha-automation-action-parallel.ts index 6ccec60232..f8a299e765 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-parallel.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-parallel.ts @@ -18,7 +18,7 @@ export class HaParallelAction extends LitElement implements ActionElement { @property({ attribute: false }) public action!: ParallelAction; - public static get defaultConfig() { + public static get defaultConfig(): ParallelAction { return { parallel: [], }; diff --git a/src/panels/config/automation/action/types/ha-automation-action-repeat.ts b/src/panels/config/automation/action/types/ha-automation-action-repeat.ts index 2b1cf924a9..28c1a97bb8 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-repeat.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-repeat.ts @@ -31,7 +31,7 @@ export class HaRepeatAction extends LitElement implements ActionElement { @property({ type: Array }) public path?: ItemPath; - public static get defaultConfig() { + public static get defaultConfig(): RepeatAction { return { repeat: { count: 2, sequence: [] } }; } diff --git a/src/panels/config/automation/action/types/ha-automation-action-sequence.ts b/src/panels/config/automation/action/types/ha-automation-action-sequence.ts index d8621dafa2..a8c16d6bed 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-sequence.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-sequence.ts @@ -19,7 +19,7 @@ export class HaSequenceAction extends LitElement implements ActionElement { @property({ attribute: false }) public action!: SequenceAction; - public static get defaultConfig() { + public static get defaultConfig(): SequenceAction { return { sequence: [], }; 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 6bb209a0a2..3aef27db02 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 @@ -52,7 +52,7 @@ export class HaServiceAction extends LitElement implements ActionElement { } ); - public static get defaultConfig() { + public static get defaultConfig(): ServiceAction { return { action: "", data: {} }; } diff --git a/src/panels/config/automation/action/types/ha-automation-action-set_conversation_response.ts b/src/panels/config/automation/action/types/ha-automation-action-set_conversation_response.ts index b4c9b9c51d..4592ea2401 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-set_conversation_response.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-set_conversation_response.ts @@ -25,7 +25,7 @@ export class HaSetConversationResponseAction @property({ type: Boolean }) public disabled = false; - public static get defaultConfig() { + public static get defaultConfig(): SetConversationResponseAction { return { set_conversation_response: "" }; } diff --git a/src/panels/config/automation/action/types/ha-automation-action-stop.ts b/src/panels/config/automation/action/types/ha-automation-action-stop.ts index c98a5e2cff..e5d21e96ee 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-stop.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-stop.ts @@ -14,7 +14,7 @@ export class HaStopAction extends LitElement implements ActionElement { @property({ type: Boolean }) public disabled = false; - public static get defaultConfig() { + public static get defaultConfig(): StopAction { return { stop: "" }; } diff --git a/src/panels/config/automation/action/types/ha-automation-action-wait_for_trigger.ts b/src/panels/config/automation/action/types/ha-automation-action-wait_for_trigger.ts index 52b8476a31..78c2149aa7 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-wait_for_trigger.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-wait_for_trigger.ts @@ -25,7 +25,7 @@ export class HaWaitForTriggerAction @property({ attribute: false }) public path?: ItemPath; - public static get defaultConfig() { + public static get defaultConfig(): WaitForTriggerAction { return { wait_for_trigger: [] }; } diff --git a/src/panels/config/automation/action/types/ha-automation-action-wait_template.ts b/src/panels/config/automation/action/types/ha-automation-action-wait_template.ts index 01f708ff3e..d8aa32296c 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-wait_template.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-wait_template.ts @@ -34,7 +34,7 @@ export class HaWaitAction extends LitElement implements ActionElement { @property({ type: Boolean }) public disabled = false; - public static get defaultConfig() { + public static get defaultConfig(): WaitAction { return { wait_template: "", continue_on_timeout: true }; } diff --git a/src/panels/config/automation/condition/ha-automation-condition.ts b/src/panels/config/automation/condition/ha-automation-condition.ts index d164a6ee21..4ee3e674b4 100644 --- a/src/panels/config/automation/condition/ha-automation-condition.ts +++ b/src/panels/config/automation/condition/ha-automation-condition.ts @@ -207,10 +207,9 @@ export default class HaAutomationCondition extends LitElement { const elClass = customElements.get( `ha-automation-condition-${condition}` ) as CustomElementConstructor & { - defaultConfig: Omit; + defaultConfig: Condition; }; conditions = this.conditions.concat({ - condition: condition as any, ...elClass.defaultConfig, }); } diff --git a/src/panels/config/automation/condition/types/ha-automation-condition-and.ts b/src/panels/config/automation/condition/types/ha-automation-condition-and.ts index 482d593d91..ee7fa15d90 100644 --- a/src/panels/config/automation/condition/types/ha-automation-condition-and.ts +++ b/src/panels/config/automation/condition/types/ha-automation-condition-and.ts @@ -1,8 +1,16 @@ import { customElement } from "lit/decorators"; import { HaLogicalCondition } from "./ha-automation-condition-logical"; +import { LogicalCondition } from "../../../../../data/automation"; @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 { interface HTMLElementTagNameMap { diff --git a/src/panels/config/automation/condition/types/ha-automation-condition-device.ts b/src/panels/config/automation/condition/types/ha-automation-condition-device.ts index 2e6faadaf9..a0dcee2cd9 100644 --- a/src/panels/config/automation/condition/types/ha-automation-condition-device.ts +++ b/src/panels/config/automation/condition/types/ha-automation-condition-device.ts @@ -36,8 +36,9 @@ export class HaDeviceCondition extends LitElement { private _origCondition?: DeviceCondition; - public static get defaultConfig() { + public static get defaultConfig(): DeviceCondition { return { + condition: "device", device_id: "", domain: "", entity_id: "", diff --git a/src/panels/config/automation/condition/types/ha-automation-condition-logical.ts b/src/panels/config/automation/condition/types/ha-automation-condition-logical.ts index 4716131c35..caa875377d 100644 --- a/src/panels/config/automation/condition/types/ha-automation-condition-logical.ts +++ b/src/panels/config/automation/condition/types/ha-automation-condition-logical.ts @@ -7,7 +7,10 @@ import "../ha-automation-condition"; import type { ConditionElement } from "../ha-automation-condition-row"; @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 condition!: LogicalCondition; @@ -16,12 +19,6 @@ export class HaLogicalCondition extends LitElement implements ConditionElement { @property({ attribute: false }) public path?: ItemPath; - public static get defaultConfig() { - return { - conditions: [], - }; - } - protected render() { return html` ; + defaultConfig: Trigger; }; triggers = this.triggers.concat({ - platform: platform as any, ...elClass.defaultConfig, }); } diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-calendar.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-calendar.ts index 44754c8b31..a1f7b2d54f 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-calendar.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-calendar.ts @@ -69,10 +69,12 @@ export class HaCalendarTrigger extends LitElement implements TriggerElement { ] as const ); - public static get defaultConfig() { + public static get defaultConfig(): CalendarTrigger { return { + platform: "calendar", + entity_id: "", event: "start" as CalendarTrigger["event"], - offset: 0, + offset: "0", }; } diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-conversation.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-conversation.ts index 4cb5abd86b..7a7ba188fa 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-conversation.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-conversation.ts @@ -25,8 +25,8 @@ export class HaConversationTrigger @query("#option_input", true) private _optionInput?: HaTextField; - public static get defaultConfig(): Omit { - return { command: "" }; + public static get defaultConfig(): ConversationTrigger { + return { platform: "conversation", command: "" }; } protected render() { diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-device.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-device.ts index c69c21b68c..660f43beb9 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-device.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-device.ts @@ -38,8 +38,9 @@ export class HaDeviceTrigger extends LitElement { private _origTrigger?: DeviceTrigger; - public static get defaultConfig() { + public static get defaultConfig(): DeviceTrigger { return { + platform: "device", device_id: "", domain: "", entity_id: "", diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-event.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-event.ts index 5904efdba5..2685ff25f1 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-event.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-event.ts @@ -19,8 +19,8 @@ export class HaEventTrigger extends LitElement implements TriggerElement { @property({ type: Boolean }) public disabled = false; - public static get defaultConfig() { - return { event_type: "" }; + public static get defaultConfig(): EventTrigger { + return { platform: "event", event_type: "" }; } protected render() { diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-geo_location.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-geo_location.ts index 849a91b2d8..38605caeed 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-geo_location.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-geo_location.ts @@ -43,8 +43,9 @@ export class HaGeolocationTrigger extends LitElement { ] as const ); - public static get defaultConfig() { + public static get defaultConfig(): GeoLocationTrigger { return { + platform: "geo_location", source: "", zone: "", event: "enter" as GeoLocationTrigger["event"], diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-homeassistant.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-homeassistant.ts index d0d9629d7e..94f241a93a 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-homeassistant.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-homeassistant.ts @@ -41,8 +41,9 @@ export class HaHassTrigger extends LitElement { ] as const ); - public static get defaultConfig() { + public static get defaultConfig(): HassTrigger { return { + platform: "homeassistant", event: "start" as HassTrigger["event"], }; } diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-mqtt.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-mqtt.ts index e01df554e9..78a4874880 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-mqtt.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-mqtt.ts @@ -20,8 +20,8 @@ export class HaMQTTTrigger extends LitElement implements TriggerElement { @property({ type: Boolean }) public disabled = false; - public static get defaultConfig() { - return { topic: "" }; + public static get defaultConfig(): MqttTrigger { + return { platform: "mqtt", topic: "" }; } protected render() { diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-numeric_state.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-numeric_state.ts index f2d0d72e5f..f7b812c511 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-numeric_state.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-numeric_state.ts @@ -237,8 +237,9 @@ export class HaNumericStateTrigger extends LitElement { } } - public static get defaultConfig() { + public static get defaultConfig(): NumericStateTrigger { return { + platform: "numeric_state", entity_id: [], }; } diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-persistent_notification.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-persistent_notification.ts index ee3a1743d4..f08ef50a09 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-persistent_notification.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-persistent_notification.ts @@ -70,8 +70,9 @@ export class HaPersistentNotificationTrigger ] as const ); - public static get defaultConfig() { + public static get defaultConfig(): PersistentNotificationTrigger { return { + platform: "persistent_notification", update_type: [...DEFAULT_UPDATE_TYPES], notification_id: DEFAULT_NOTIFICATION_ID, }; diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-state.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-state.ts index 4899fb19ee..51f5503074 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-state.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-state.ts @@ -48,8 +48,8 @@ export class HaStateTrigger extends LitElement implements TriggerElement { @property({ type: Boolean }) public disabled = false; - public static get defaultConfig() { - return { entity_id: [] }; + public static get defaultConfig(): StateTrigger { + return { platform: "state", entity_id: [] }; } private _schema = memoizeOne( diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-sun.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-sun.ts index 3696952110..a60db83391 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-sun.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-sun.ts @@ -43,8 +43,9 @@ export class HaSunTrigger extends LitElement implements TriggerElement { ] as const ); - public static get defaultConfig() { + public static get defaultConfig(): SunTrigger { return { + platform: "sun", event: "sunrise" as SunTrigger["event"], offset: 0, }; diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-tag.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-tag.ts index 7857ea17b5..e7f82d8c77 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-tag.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-tag.ts @@ -19,8 +19,8 @@ export class HaTagTrigger extends LitElement implements TriggerElement { @state() private _tags?: Tag[]; - public static get defaultConfig() { - return { tag_id: "" }; + public static get defaultConfig(): TagTrigger { + return { platform: "tag", tag_id: "" }; } protected firstUpdated(changedProperties: PropertyValues) { diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-template.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-template.ts index b1c85eb460..a12464b22f 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-template.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-template.ts @@ -22,8 +22,8 @@ export class HaTemplateTrigger extends LitElement { @property({ type: Boolean }) public disabled = false; - public static get defaultConfig() { - return { value_template: "" }; + public static get defaultConfig(): TemplateTrigger { + return { platform: "template", value_template: "" }; } public willUpdate(changedProperties: PropertyValues) { diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-time.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-time.ts index c2b23d175c..e7db9bba11 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-time.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-time.ts @@ -19,8 +19,8 @@ export class HaTimeTrigger extends LitElement implements TriggerElement { @state() private _inputMode?: boolean; - public static get defaultConfig() { - return { at: "" }; + public static get defaultConfig(): TimeTrigger { + return { platform: "time", at: "" }; } private _schema = memoizeOne( diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-time_pattern.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-time_pattern.ts index 862ce881f6..9217495673 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-time_pattern.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-time_pattern.ts @@ -21,8 +21,8 @@ export class HaTimePatternTrigger extends LitElement implements TriggerElement { @property({ type: Boolean }) public disabled = false; - public static get defaultConfig() { - return {}; + public static get defaultConfig(): TimePatternTrigger { + return { platform: "time_pattern" }; } protected render() { diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-webhook.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-webhook.ts index 86bee36fb5..9adf5a05d5 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-webhook.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-webhook.ts @@ -36,8 +36,9 @@ export class HaWebhookTrigger extends LitElement { private _unsub?: UnsubscribeFunc; - public static get defaultConfig() { + public static get defaultConfig(): WebhookTrigger { return { + platform: "webhook", allowed_methods: [...DEFAULT_METHODS], local_only: true, webhook_id: DEFAULT_WEBHOOK_ID, diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-zone.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-zone.ts index 7ddf87ccdf..fa0676094d 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-zone.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-zone.ts @@ -23,8 +23,9 @@ export class HaZoneTrigger extends LitElement { @property({ type: Boolean }) public disabled = false; - public static get defaultConfig() { + public static get defaultConfig(): ZoneTrigger { return { + platform: "zone", entity_id: "", zone: "", event: "enter" as ZoneTrigger["event"],