diff --git a/gallery/src/pages/automation/editor-trigger.ts b/gallery/src/pages/automation/editor-trigger.ts
index 885c8da7d0e6..1f962bd39fee 100644
--- a/gallery/src/pages/automation/editor-trigger.ts
+++ b/gallery/src/pages/automation/editor-trigger.ts
@@ -18,7 +18,6 @@ import { HaEventTrigger } from "../../../../src/panels/config/automation/trigger
import { HaGeolocationTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-geo_location";
import { HaHassTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-homeassistant";
import { HaTriggerList } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-list";
-import { HaMQTTTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-mqtt";
import { HaNumericStateTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-numeric_state";
import { HaPersistentNotificationTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-persistent_notification";
import { HaStateTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-state";
@@ -38,11 +37,6 @@ const SCHEMAS: { name: string; triggers: Trigger[] }[] = [
triggers: [{ ...HaStateTrigger.defaultConfig }],
},
- {
- name: "MQTT",
- triggers: [{ ...HaMQTTTrigger.defaultConfig }],
- },
-
{
name: "GeoLocation",
triggers: [{ ...HaGeolocationTrigger.defaultConfig }],
diff --git a/src/data/automation.ts b/src/data/automation.ts
index d544978630af..7b6578c06a5e 100644
--- a/src/data/automation.ts
+++ b/src/data/automation.ts
@@ -114,12 +114,6 @@ export interface StateTrigger extends BaseTrigger {
for?: string | number | ForDict;
}
-export interface MqttTrigger extends BaseTrigger {
- trigger: "mqtt";
- topic: string;
- payload?: string;
-}
-
export interface GeoLocationTrigger extends BaseTrigger {
trigger: "geo_location";
source: string;
@@ -127,6 +121,12 @@ export interface GeoLocationTrigger extends BaseTrigger {
event: "enter" | "leave";
}
+export interface MqttTrigger extends BaseTrigger {
+ trigger: "mqtt";
+ topic: string;
+ payload?: string;
+}
+
export interface HassTrigger extends BaseTrigger {
trigger: "homeassistant";
event: "start" | "shutdown";
diff --git a/src/data/trigger.ts b/src/data/trigger.ts
index c8204d68fe25..f70d00994b14 100644
--- a/src/data/trigger.ts
+++ b/src/data/trigger.ts
@@ -40,7 +40,6 @@ export const TRIGGER_COLLECTIONS: AutomationElementGroupCollection[] = [
event: {},
geo_location: {},
homeassistant: {},
- mqtt: {},
conversation: {},
tag: {},
template: {},
diff --git a/src/panels/config/automation/trigger/ha-automation-trigger-row.ts b/src/panels/config/automation/trigger/ha-automation-trigger-row.ts
index 40297a031405..0d9b68a6eda4 100644
--- a/src/panels/config/automation/trigger/ha-automation-trigger-row.ts
+++ b/src/panels/config/automation/trigger/ha-automation-trigger-row.ts
@@ -72,7 +72,6 @@ import "./types/ha-automation-trigger-event";
import "./types/ha-automation-trigger-geo_location";
import "./types/ha-automation-trigger-homeassistant";
import "./types/ha-automation-trigger-list";
-import "./types/ha-automation-trigger-mqtt";
import "./types/ha-automation-trigger-numeric_state";
import "./types/ha-automation-trigger-persistent_notification";
import "./types/ha-automation-trigger-platform";
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
deleted file mode 100644
index c42a9f10be11..000000000000
--- a/src/panels/config/automation/trigger/types/ha-automation-trigger-mqtt.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import { html, LitElement } from "lit";
-import { customElement, property } from "lit/decorators";
-import { fireEvent } from "../../../../../common/dom/fire_event";
-import "../../../../../components/ha-form/ha-form";
-import type { SchemaUnion } from "../../../../../components/ha-form/types";
-import type { MqttTrigger } from "../../../../../data/automation";
-import type { HomeAssistant } from "../../../../../types";
-import type { TriggerElement } from "../ha-automation-trigger-row";
-
-const SCHEMA = [
- { name: "topic", required: true, selector: { text: {} } },
- { name: "payload", selector: { text: {} } },
-] as const;
-
-@customElement("ha-automation-trigger-mqtt")
-export class HaMQTTTrigger extends LitElement implements TriggerElement {
- @property({ attribute: false }) public hass!: HomeAssistant;
-
- @property({ attribute: false }) public trigger!: MqttTrigger;
-
- @property({ type: Boolean }) public disabled = false;
-
- public static get defaultConfig(): MqttTrigger {
- return { trigger: "mqtt", topic: "" };
- }
-
- protected render() {
- return html`
-
- `;
- }
-
- private _valueChanged(ev: CustomEvent): void {
- ev.stopPropagation();
- const newTrigger = ev.detail.value;
- fireEvent(this, "value-changed", { value: newTrigger });
- }
-
- private _computeLabelCallback = (
- schema: SchemaUnion
- ): string =>
- this.hass.localize(
- `ui.panel.config.automation.editor.triggers.type.mqtt.${schema.name}`
- );
-}
-
-declare global {
- interface HTMLElementTagNameMap {
- "ha-automation-trigger-mqtt": HaMQTTTrigger;
- }
-}
diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-platform.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-platform.ts
index bdf8f0145ccb..12c0f0611fa5 100644
--- a/src/panels/config/automation/trigger/types/ha-automation-trigger-platform.ts
+++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-platform.ts
@@ -25,6 +25,16 @@ const showOptionalToggle = (field: TriggerDescription["fields"][string]) =>
!field.required &&
!("boolean" in field.selector && field.default);
+const DEFAULT_KEYS: (keyof PlatformTrigger)[] = [
+ "trigger",
+ "target",
+ "alias",
+ "id",
+ "variables",
+ "enabled",
+ "options",
+] as const;
+
@customElement("ha-automation-trigger-platform")
export class HaPlatformTrigger extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@@ -52,6 +62,31 @@ export class HaPlatformTrigger extends LitElement {
if (!changedProperties.has("trigger")) {
return;
}
+
+ let newValue: PlatformTrigger | undefined;
+
+ for (const key in this.trigger) {
+ // Migrate old options to `options`
+ if (DEFAULT_KEYS.includes(key as keyof PlatformTrigger)) {
+ continue;
+ }
+ if (newValue === undefined) {
+ newValue = {
+ ...this.trigger,
+ options: { [key]: this.trigger[key] },
+ };
+ } else {
+ newValue.options![key] = this.trigger[key];
+ }
+ delete newValue[key];
+ }
+ if (newValue !== undefined) {
+ fireEvent(this, "value-changed", {
+ value: newValue,
+ });
+ this.trigger = newValue;
+ }
+
const oldValue = changedProperties.get("trigger") as
| undefined
| this["trigger"];