Delete dynamic scene?

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?

1 Like

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.

Good to know I’m not missing something.

It seems that calling create with an empty snapshot_entities array or entities dict has no effect, hence the work-around of doing:

{
    "scene_id": "before_outsite_lighting",
    "snapshot_entities": [
        "sun.sun"
    ]
}

It seems to work since I can’t change the sun state by re-running the scene.

1 Like

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.

Does it really matter if they will be removed at the next reload?

oh…that was the missing piece for me! I had no idea. I guess i have not reloaded for a long long time!

1 Like

What the hell?

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.

I believe there sometimes is a need to delete and I’ve detailed a use case here.

thanks for the info here . i figured it out and will give a node red example if that helps anyone