diff --git a/gallery/src/pages/automation/editor-action.ts b/gallery/src/pages/automation/editor-action.ts index 7f45fc83ad..b7bb254c21 100644 --- a/gallery/src/pages/automation/editor-action.ts +++ b/gallery/src/pages/automation/editor-action.ts @@ -15,7 +15,6 @@ import { HaDelayAction } from "../../../../src/panels/config/automation/action/t import { HaDeviceAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-device_id"; import { HaEventAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-event"; import { HaRepeatAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-repeat"; -import { HaSceneAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-activate_scene"; import { HaServiceAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-service"; import { HaWaitForTriggerAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-wait_for_trigger"; import { HaWaitAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-wait_template"; @@ -33,7 +32,6 @@ const SCHEMAS: { name: string; actions: Action[] }[] = [ { name: "Service", actions: [HaServiceAction.defaultConfig] }, { name: "Condition", actions: [HaConditionAction.defaultConfig] }, { name: "Delay", actions: [HaDelayAction.defaultConfig] }, - { name: "Scene", actions: [HaSceneAction.defaultConfig] }, { name: "Play media", actions: [HaPlayMediaAction.defaultConfig] }, { name: "Wait", actions: [HaWaitAction.defaultConfig] }, { name: "WaitForTrigger", actions: [HaWaitForTriggerAction.defaultConfig] }, diff --git a/src/data/action.ts b/src/data/action.ts index 44eb8ca18b..37ce9c8e70 100644 --- a/src/data/action.ts +++ b/src/data/action.ts @@ -11,7 +11,6 @@ import { mdiFormatListNumbered, mdiGestureDoubleTap, mdiHandBackRight, - mdiPalette, mdiPlay, mdiRefresh, mdiRoomService, @@ -27,7 +26,6 @@ export const ACTION_ICONS = { delay: mdiTimerOutline, event: mdiGestureDoubleTap, play_media: mdiPlay, - activate_scene: mdiPalette, service: mdiRoomService, wait_template: mdiCodeBraces, wait_for_trigger: mdiTrafficLight, diff --git a/src/data/script.ts b/src/data/script.ts index c7e08fc129..473ae574ef 100644 --- a/src/data/script.ts +++ b/src/data/script.ts @@ -72,16 +72,6 @@ const playMediaActionStruct: Describe = assign( }) ); -const activateSceneActionStruct: Describe = assign( - baseActionStruct, - object({ - action: literal("scene.turn_on"), - target: optional(object({ entity_id: optional(string()) })), - entity_id: optional(string()), - metadata: object(), - }) -); - export interface ScriptEntity extends HassEntityBase { attributes: HassEntityAttributeBase & { last_triggered: string; @@ -161,17 +151,6 @@ export interface DelayAction extends BaseAction { delay: number | Partial | string; } -export interface ServiceSceneAction extends BaseAction { - action: "scene.turn_on"; - target?: { entity_id?: string }; - entity_id?: string; - metadata: Record; -} -export interface LegacySceneAction extends BaseAction { - scene: string; -} -export type SceneAction = ServiceSceneAction | LegacySceneAction; - export interface WaitAction extends BaseAction { wait_template: string; timeout?: number; @@ -272,7 +251,6 @@ export type NonConditionAction = | DeviceAction | ServiceAction | DelayAction - | SceneAction | WaitAction | WaitForTriggerAction | RepeatAction @@ -298,7 +276,6 @@ export interface ActionTypes { check_condition: Condition; fire_event: EventAction; device_action: DeviceAction; - activate_scene: SceneAction; repeat: RepeatAction; choose: ChooseAction; if: IfAction; @@ -381,9 +358,6 @@ export const getActionType = (action: Action): ActionType => { if ("device_id" in action) { return "device_action"; } - if ("scene" in action) { - return "activate_scene"; - } if ("repeat" in action) { return "repeat"; } @@ -413,9 +387,6 @@ export const getActionType = (action: Action): ActionType => { } if ("action" in action || "service" in action) { if ("metadata" in action) { - if (is(action, activateSceneActionStruct)) { - return "activate_scene"; - } if (is(action, playMediaActionStruct)) { return "play_media"; } @@ -447,6 +418,15 @@ export const migrateAutomationAction = ( delete action.service; } + // legacy scene (scene: scene_name) + if ("scene" in action) { + action.action = "scene.turn_on"; + action.target = { + entity_id: action.scene, + }; + delete action.scene; + } + if ("sequence" in action) { for (const sequenceAction of (action as SequenceAction).sequence) { migrateAutomationAction(sequenceAction); diff --git a/src/data/script_i18n.ts b/src/data/script_i18n.ts index 03b7f69fd7..c14fd7f137 100644 --- a/src/data/script_i18n.ts +++ b/src/data/script_i18n.ts @@ -28,7 +28,6 @@ import type { ParallelAction, PlayMediaAction, RepeatAction, - SceneAction, SequenceAction, SetConversationResponseAction, StopAction, @@ -297,26 +296,6 @@ const tryDescribeAction = ( }); } - if (actionType === "activate_scene") { - const config = action as SceneAction; - let entityId: string | undefined; - if ("scene" in config) { - entityId = config.scene; - } else { - entityId = config.target?.entity_id || config.entity_id; - } - if (!entityId) { - return hass.localize( - `${actionTranslationBaseKey}.activate_scene.description.activate_scene` - ); - } - const sceneStateObj = entityId ? hass.states[entityId] : undefined; - return hass.localize( - `${actionTranslationBaseKey}.activate_scene.description.activate_scene_with_name`, - { name: sceneStateObj ? computeStateName(sceneStateObj) : entityId } - ); - } - if (actionType === "play_media") { const config = action as PlayMediaAction; const entityId = config.target?.entity_id || config.entity_id; diff --git a/src/panels/config/automation/action/ha-automation-action-row.ts b/src/panels/config/automation/action/ha-automation-action-row.ts index 4edb59acfb..dd678e3b84 100644 --- a/src/panels/config/automation/action/ha-automation-action-row.ts +++ b/src/panels/config/automation/action/ha-automation-action-row.ts @@ -60,7 +60,6 @@ import { import { haStyle } from "../../../../resources/styles"; import type { HomeAssistant } from "../../../../types"; import { showToast } from "../../../../util/toast"; -import "./types/ha-automation-action-activate_scene"; import "./types/ha-automation-action-choose"; import "./types/ha-automation-action-condition"; import "./types/ha-automation-action-delay"; @@ -81,8 +80,8 @@ export const getType = (action: Action | undefined) => { if (!action) { return undefined; } - if ("action" in action || "scene" in action) { - return getActionType(action) as "activate_scene" | "action" | "play_media"; + if ("action" in action) { + return getActionType(action) as "action" | "play_media"; } if (["and", "or", "not"].some((key) => key in action)) { return "condition" as const; diff --git a/src/panels/config/automation/action/types/ha-automation-action-activate_scene.ts b/src/panels/config/automation/action/types/ha-automation-action-activate_scene.ts deleted file mode 100644 index bf01fce06a..0000000000 --- a/src/panels/config/automation/action/types/ha-automation-action-activate_scene.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { html, LitElement } from "lit"; -import { customElement, property } from "lit/decorators"; -import { fireEvent } from "../../../../../common/dom/fire_event"; -import "../../../../../components/entity/ha-entity-picker"; -import type { SceneAction } from "../../../../../data/script"; -import type { ValueChangedEvent, HomeAssistant } from "../../../../../types"; -import type { ActionElement } from "../ha-automation-action-row"; - -const includeDomains = ["scene"]; - -@customElement("ha-automation-action-activate_scene") -export class HaSceneAction extends LitElement implements ActionElement { - @property({ attribute: false }) public hass!: HomeAssistant; - - @property({ type: Boolean }) public disabled = false; - - @property({ attribute: false }) public action!: SceneAction; - - public static get defaultConfig(): SceneAction { - return { - action: "scene.turn_on", - target: { - entity_id: "", - }, - metadata: {}, - }; - } - - protected render() { - let scene; - - if ("scene" in this.action) { - scene = this.action.scene; - } else { - scene = this.action.target?.entity_id; - } - - return html` - - `; - } - - private _entityPicked(ev: ValueChangedEvent) { - ev.stopPropagation(); - fireEvent(this, "value-changed", { - value: { - ...this.action, - action: "scene.turn_on", - target: { - entity_id: ev.detail.value, - }, - metadata: {}, - } as SceneAction, - }); - } -} - -declare global { - interface HTMLElementTagNameMap { - "ha-automation-action-activate_scene": HaSceneAction; - } -} diff --git a/src/translations/en.json b/src/translations/en.json index 92ad97e819..28722c0f0f 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -3495,14 +3495,6 @@ "no_device": "Device action" } }, - "activate_scene": { - "label": "Scene", - "scene": "Scene", - "description": { - "activate_scene": "Activate a scene", - "activate_scene_with_name": "Activate scene {name}" - } - }, "repeat": { "label": "Repeat", "type_select": "Repeat type",