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

2b691285ee

* Revert "Update docs to match changes upstream"

This reverts commit 502c4f8afc309e25e61f74fd837c4253e296dce6.
The reason is the reversal of the upstream functionality
7f0108059b

---------

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
Tudor Sandu 2023-11-25 11:19:54 -08:00 committed by GitHub
parent 6a8f51b94f
commit 1d77078397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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