Init new scenes in live edit mode (#23051)

* Init new scenes in live edit mode

* Update src/panels/config/scene/ha-scene-editor.ts

Co-authored-by: Simon Lamon <32477463+silamon@users.noreply.github.com>

* imports

---------

Co-authored-by: Simon Lamon <32477463+silamon@users.noreply.github.com>
This commit is contained in:
karwosts 2024-12-02 02:18:03 -08:00 committed by GitHub
parent 90b7cad7ac
commit f72b298f97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 7 deletions

View File

@ -7,7 +7,9 @@ import {
mdiContentSave,
mdiDelete,
mdiDotsVertical,
mdiEye,
mdiInformationOutline,
mdiMotionPlayOutline,
mdiPlay,
mdiTag,
} from "@mdi/js";
@ -204,6 +206,14 @@ export class HaSceneEditor extends SubscribeMixin(
}
);
public connectedCallback() {
super.connectedCallback();
if (!this.sceneId) {
this._mode = "live";
this._subscribeEvents();
}
}
public disconnectedCallback() {
super.disconnectedCallback();
if (this._unsubscribeEvents) {
@ -387,15 +397,22 @@ export class HaSceneEditor extends SubscribeMixin(
alert-type="info"
.narrow=${this.narrow}
.title=${this.hass.localize(
`ui.panel.config.scene.editor.${this._mode === "live" ? "live_preview" : "review_mode"}`
`ui.panel.config.scene.editor.${this._mode === "live" ? "live_edit" : "review_mode"}`
)}
>
${this.hass.localize(
`ui.panel.config.scene.editor.${this._mode === "live" ? "live_preview_detail" : "review_mode_detail"}`
`ui.panel.config.scene.editor.${this._mode === "live" ? "live_edit_detail" : "review_mode_detail"}`
)}
<span slot="icon">
<ha-svg-icon
.path=${this._mode === "live"
? mdiMotionPlayOutline
: mdiEye}
></ha-svg-icon>
</span>
<ha-button slot="action" @click=${this._toggleLiveMode}>
${this.hass.localize(
`ui.panel.config.scene.editor.${this._mode === "live" ? "back_to_review_mode" : "live_preview"}`
`ui.panel.config.scene.editor.${this._mode === "live" ? "switch_to_review_mode" : "live_edit"}`
)}
</ha-button>
</ha-alert>

View File

@ -3878,11 +3878,11 @@
},
"editor": {
"review_mode": "Review Mode",
"review_mode_detail": "You can adjust the scene's details and remove devices or entities. To fully edit, switch to Live Preview, which will apply the scene.",
"live_preview": "Live Preview",
"live_preview_detail": "In Live Preview, all changes to this scene are applied in real-time to your devices and entities.",
"review_mode_detail": "You can adjust the scene's details and remove devices or entities. To fully edit, switch to Live Edit, which will apply the scene.",
"live_edit": "Live Edit",
"live_edit_detail": "In Live Edit, all changes to this scene are applied in real-time to your devices and entities.",
"enter_live_mode_unsaved": "You have unsaved changes to this scene. Continuing to live preview will apply the saved scene, which may overwrite your unsaved changes. Consider if you would like to save the scene first before activating it.",
"back_to_review_mode": "Back to review mode",
"switch_to_review_mode": "Switch to review mode",
"default_name": "New scene",
"load_error_not_editable": "Only scenes in scenes.yaml are editable.",
"load_error_unknown": "Error loading scene ({err_no}).",