Automation A's action is not triggering automation B, help?

Hi all. I am trying to track which scene is currently activated in my bedroom (“Slaapkamer” in Dutch). In order to do so, I created a select_input helper and an automation that listens to call_service events, as so:

    alias: Slaapkamer scene tracker
    description: ''
    trigger:
      - platform: event
        event_type: call_service
        event_data:
          domain: scene
          service: turn_on
          service_data:
            entity_id: scene.slaapkamer_uit
      - platform: event
        event_type: call_service
        event_data:
          domain: scene
          service: turn_on
          service_data:
            entity_id: scene.slaapkamer_nacht
      - platform: event
        event_type: call_service
        event_data:
          domain: scene
          service: turn_on
          service_data:
            entity_id: scene.slaapkamer_fel
    condition: []
    action:
      - service: input_select.select_option
        target:
          entity_id: input_select.slaapkamer_scenes
        data_template:
          option: >-
            {{trigger.event.as_dict()['data']['service_data']['entity_id'].split('.')[1]}}
    mode: single

This works. When I activate a scene from my dashboard, the variable changes. But I also have one of those small Ikea on/off buttons. I made a different automation that makes a service call to turn on a scene when I hit the button:

    alias: Slaapkamer fel aan
    description: ''
    trigger:
      - device_id: 9953220fc20a29dd6f6ae9f2db89015b
        domain: deconz
        platform: device
        type: remote_button_short_press
        subtype: turn_on
    action:
      - service: scene.turn_on
        target:
          entity_id: scene.slaapkamer_fel
    mode: single

This automation also works. I hit the button and my light turns on. But when I do this, my first automation above is not triggered. But if I look at the events that get triggered, I do see the correct event:

    {
        "event_type": "call_service",
        "data": {
            "domain": "scene",
            "service": "turn_on",
            "service_data": {
                "entity_id": [
                    "scene.slaapkamer_fel"
                ]
            }
        },
        "origin": "LOCAL",
        "time_fired": "2021-08-07T19:22:17.792653+00:00",
        "context": {
            "id": "3cd2a7224b072a834e13adf8c7755e11",
            "parent_id": "6fecf59f5b1223ee63a1cf1d2b626458",
            "user_id": null
        }
    }

Does anyone know why? Any idea how I can fix this? It does appear as if there is a difference between the entity_id when I activate a scene from the dashboard (a string) versus the event that I get from the button automation (an array containing a single string). Where does the difference come from? I do supply a string in my automation. Thanks in advance!

1 Like

I can confirm that if a scene is executed via the Configuration > Scenes menu, the value of entity_id is a string.

{
    "event_type": "call_service",
    "data": {
        "domain": "scene",
        "service": "turn_on",
        "service_data": {
            "entity_id": "scene.test_1"
        }

If I execute the same scene by calling the scene.turn_on service, the value of entity_id is a list.

{
    "event_type": "call_service",
    "data": {
        "domain": "scene",
        "service": "turn_on",
        "service_data": {
            "entity_id": [
                "scene.test_1"
            ]
        }

I don’t know why the two methods present the information differently.

If you modify your three Event Triggers like shown below they will trigger when you call scene.turn_on as a service. However, this modification will prevent them from triggering when you execute a scene from the menu.

      - platform: event
        event_type: call_service
        event_data:
          domain: scene
          service: turn_on
          service_data:
            entity_id:
              - scene.slaapkamer_uit
      - platform: event
        event_type: call_service
        event_data:
          domain: scene
          service: turn_on
          service_data:
            entity_id:
              - scene.slaapkamer_nacht
      - platform: event
        event_type: call_service
        event_data:
          domain: scene
          service: turn_on
          service_data:
            entity_id:
              - scene.slaapkamer_fel.

Thank you. Any idea why the formats don’t match? Any why it even matters? According to the automation trigger documentation it should be possible to listen to multiple entity IDs on the same trigger.

My initial draft of my scene tracker was:

alias: Slaapkamer scene tracker
    description: ''
    trigger:
      - platform: event
        event_type: call_service
        event_data:
          domain: scene
          service: turn_on
          service_data:
            entity_id:
              - scene.slaapkamer_uit
              - scene.slaapkamer_nacht
              - scene.slaapkamer_fel

I would expect that this trigger would match all dashboard scene changes and all automatiion scene changes, as long as any of the entity IDs listed in the trigger matches any of the entity IDs in the event. Is this a HA bug maybe?

For a State Trigger.

That’s not how I read the documentation. Anyway, I have duplicated the triggers. Now I have 6 triggers total (3 as array and 3 as string) so now it works. I’ve marked your answer as accepted. Thank you! :smiley:

Looks like you had the same interpretation as I originally did. The documentation gives the impression that you can list multiple entity_ids for other triggers as well. I even reported Event Trigger’s inability to do it as a bug but was informed it was not a bug but my misinterpretation of the documentation.

It allegedly works for all triggers that have an entity_id option (but not Event Trigger because entity_id is not a direct option but buried deep within event_data). I intended to clarify the documentation but never did because I wanted to test all triggers first but don’t have a means of testing Zone Trigger (and no one answered my question if it did).