From 1d770783970103ebd0d2a0eca6c666dbde893061 Mon Sep 17 00:00:00 2001 From: Tudor Sandu Date: Sat, 25 Nov 2023 11:19:54 -0800 Subject: [PATCH] Add scene.delete service for dynamically created scenes (with scene.create) (#26504) * Add scene.delete service * remove unneeded newline * Update docs to match changes upstream https://github.com/home-assistant/core/pull/89090/commits/2b691285eec92380b333970442e55af7e8869896 * Revert "Update docs to match changes upstream" This reverts commit 502c4f8afc309e25e61f74fd837c4253e296dce6. The reason is the reversal of the upstream functionality https://github.com/home-assistant/core/pull/89090/commits/7f0108059be140081847a046a5ab9b42b6beece5 --------- Co-authored-by: Franck Nijhof --- source/_integrations/scene.markdown | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/source/_integrations/scene.markdown b/source/_integrations/scene.markdown index a4f2b526d90..9c8582bb122 100644 --- a/source/_integrations/scene.markdown +++ b/source/_integrations/scene.markdown @@ -192,6 +192,27 @@ automation: source: HDMI 1 ``` +## Deleting dynamically created scenes + +Any scene that you have created with the `scene.create` service can also be deleted on demand with the `scene.delete` service. + +You will need to pass in the `entity_id` of such a scene. As opposed to the `scene_id` used for creation, the `entity_id` must also include the `scene` domain. + +If the scene was not previously created by `scene.create`, the service call will fail and an error will appear in the logs. + +```yaml +# Example automation +automation: + trigger: + platform: state + entity_id: sun.sun + to: below_horizon + action: + - service: scene.delete + data: + entity_id: scene.my_scene +``` + The following example turns off some entities as soon as a window opens. The states of the entities are restored after the window is closed again. ```yaml