Trigger Automation when Scene is triggered

Home Assistant release (hass --version):
0.35

Python release (python3 --version):
3.4.2

Component/platform:
scene and automation

Description of problem:
When my sleep-scene is triggered, I want to also call an automation.

I do not think that currently is possible.
You can have à script in the frontend, that also trigger the scene

This works:

scene:
  - name: Test
    entities:
      light.test:
        state: on

automation:
  - alias: 'Event trigger'
    trigger:
      platform: event
      event_type: call_service
      event_data:
        service_data:
          entity_id: [scene.test]
        domain: scene
        service: turn_on
    action:
      service: homeassistant.turn_on
      entity_id: script.telegram
      data:
        variables:
          message: 'Test scene was turned on!'
5 Likes

Works like a charm. Thanks a lot!

1 Like

This is not working for me, and I don’t understand why. It seems like the automation is not triggered at all. This is my code in automations.yaml:

- alias: Spegnimento luci
  trigger:
    platform: event
    event_type: call_service
    event_data:
      service_data:
        entity_id: scene.spengi_tutto
      domain: scene
      service: turn_on
  action:
    service: tts.google_say
    entity_id: media_player.altoparlante
    data:
      variables:
        message: "Le luci sono spente."

Any ideas?

Could it be your double quotes in the last line?

I tried also with single quotes and different actions, but it still doesn’t work, so the problem must be in the trigger.

Edit: I’ve updated to 0.38.1 and now everything is working fine. I’ve no idea why, but I’m happy with that :smiley:

I’m trying to create an automation that triggers on every scene activation without any luck. I tried using a syntax without the “entity_id” part but that doesn’t work (no errors in my logfile):

- alias: 'Scene Activated Notification'
  trigger:
    platform: event
    event_type: call_service
    event_data:
      service_data:
      domain: scene
      service: turn_on      
  action:   
    service: tts.amazon_polly_say
    data_template:
      entity_id: media_player.home_group
      message: 'Scene Activated'
      cache: false

When I do enter an entity_id it works but I don’t want to create an automation for every scene I have.
Any help is appreciated.

Haven’t tried this at all but maybe if you put an asterisk for entity id maybe it could work?

Or

entity_id:
    - scene.scene1
    - scene.scene2
    - scene.scene3

Not as ideal, but better.

Unfortionately both do not work.

Also tried:

entity_id: scene.scene1, scene.scene2, scene.scene3

Ah sorry, was just guessing… Probably the only way is thru appdaemon then

No problem, thanks for trying to help out :smiley:

Create a input boolean called “scene_on”, add it “on” to all of your scenes, create your automation based off of its state going from off to on.

I wonder if it is the lack of brackets for the entity id? I just tried the method outlined by martinhjelmare to trigger an automation off of a scene and it worked great. If only I knew where these magic commands came from…

I know this is a super ancient thread, but on the off chance someone is still following.

This event trigger automation works for me only if I trigger a call_service event in the Developer Tools Event tab. If I trigger the scene itself, this does no work for me. I’m new enough to HA that I’m at a loss as to how to find out why this seems to have worked for everyone else but not me…

I have what I feel is a much easier solution to this, I created a text_input that updated when any scene changed, and displayed the most recently changed scene. I then created an automation trigger based on when that text_input changed from any value to any value by simply leaving the “from” and “to” boxes empty. It successfully calls the automation every time.