Can you trigger an automation when a scene is created or deleted?

AI tells me there’s a “scene_created” event but I suspect it’s a hallucination because it doesn’t work (tested both in the developer tools and in a dummy automation). Tried googling as well but nothing comes up for that that I see. Thanks.

You can listen for related call_service events:

- trigger: event
  event_type: call_service
  event_data:
    domain: scene
    service: create
- trigger: event
  event_type: call_service
  event_data:
    domain: scene
    service: delete
1 Like

Ooh interesting! I’m not near a computer now but this particular scene is created via the Hue integration. Do you think that will also work? I will absolutely test it once I go back anyway. This is very cool, had no idea you can detect any call

I’m not sure about that… my guess would be “no”, but it’s worth a try in the Event tool. I don’t use any integrations that provide scenes, so I can’t test it.

A workaround might be to set up a template sensor that keeps a count of scene entities provided by Hue and fire on its state changing. You could use templates to determine if the value is increasing or decreasing.

1 Like

You were correct, it does not. It probably uses some internal APIs available to HA integrations that do not report to the event bus.
I’ve marked your original answer as the solution since my question didn’t explicitly mention that this scene creation happens via the Hue integration (basically, I want to catch when someone creates a new scene in a room in the Hue app – those get auto-created as HA scenes as well). So I think my question as posed + your answer can be very useful to others.
But the true answer to my problem will likely be the template idea you had. I think that’s good enough. Thanks!

  1. Go to Developer Tools → Events
  2. In Listen to events → Event to subscribe to enter entity_registry_updated
  3. Click Start Listening
  4. Create a new scene using the Hue app.
  5. Examine the details of the generated event (Home Assistant will register the creation of a new scene entity).
  6. Assuming an event was generated, use its relevant details in an Event Trigger.

Bare minimum:

trigger: event
event_type: entity_registry_updated

If you need help to fine tune the EventTrigger, post the details of the generated event.

2 Likes

Oooh interesting!! Thanks @123
I’ll play with it tomorrow and report back

this worked great, thanks!

1 Like