I’m using scene.create from node-red to capture the current state of some entities. Later in the flow I’d like to delete the scene. My current approach is to re-create it capturing the sun.sun entity which effectively makes the scene do nothing.
Is there a way to just delete the temporary scene?
Not really. Scenes you create dynamically are stored until you reload the config.
You can call scene.reload if you want, but it will delete all of your temporary scenes. There is no way to delete a scene by id.
But, if you just call scene.create again and specify the same ID, you will overwrite the scene…so I guess you could just set the scene to some dummy empty one…which I guess is what you are doing right now lol.
Did you ever find a better solution? I think that the ability to delete scenes should be a feature request. I am dragging too many temporary scenes along with no intention of ever using them again. It would be great to either enable local scenes which are only available within the context of an automation. Or to enable you to destroy (delete) a scene at the end of an automation as a cleanup task.
You can create a scene on the fly but you can’t delete it?
Sometimes the most obvious features seem to be missing from Home Assistant!
There are legitimate scenarios where you may want to delete captured scene, far more than just for “clean-up purposes.”
One such example is you capture the existing lighting setup when a motion light is activated (with the intention of applying the scene again after the motion times out) but something happens (eg. user performs specific action such as turning light off manually) and we want to make sure the scene does not get applied by the automation by deleting the recorded scene. This example is simplified from a real scenario which uses a presence detection algorithm across a few sensors but should help convey the point.
Deleting a scene, especially a scene dynamically captured as part of an automation should be an obvious option.
There is no need to delete it, you just need the logic not to load it, if the conditions change. Once scene.create is called again it will overwrite the scene.