Actions in Automations do not accept labels as targets

This Automation does work

alias: Verschattung Südseite
description: ""
trigger:
  - type: value
    platform: device
    device_id: a7d7156169ded30a51f215e20f1f8c10
    entity_id: 6ed6a52628b360e693e235cc11ff0336
    domain: sensor
    above: 120
    id: azimut_over_110
  - type: value
    platform: device
    device_id: a7d7156169ded30a51f215e20f1f8c10
    entity_id: 6ed6a52628b360e693e235cc11ff0336
    domain: sensor
    above: 200
    id: azimut_over_210
condition:
  - condition: state
    entity_id: sensor.openweathermap_condition
    state: sunny
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - azimut_over_110
          - condition: state
            entity_id: input_boolean.livingroom_cover_shadow_mode
            state: "off"
        sequence:
          - device_id: 22431c6409bab01448e2ea4c80166498
            domain: cover
            entity_id: da9fc49db104734c571fbc2eac41a289
            type: set_position
            position: 60
          - device_id: 357e912536127fd42db0491e70c71c18
            domain: cover
            entity_id: 92201f3afbba17f9c16e714dea1b70f6
            type: set_position
            position: 40
          - service: input_boolean.turn_on
            data: {}
            target:
              entity_id: input_boolean.livingroom_cover_shadow_mode
      - conditions:
          - condition: trigger
            id:
              - azimut_over_210
          - condition: state
            entity_id: input_boolean.livingroom_cover_shadow_mode
            state: "on"
        sequence:
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id: input_boolean.livingroom_cover_shadow_mode
          - service: cover.open_cover
            metadata: {}
            data: {}
            target:
              entity_id:
                - cover.livingroom_cover_window
                - cover.bathroom_cover_window
                - cover.bedroom_cover_window
mode: single

The same Automation just with the label used instead of the entities directly doesn’t work. Simply nothing happens although the trace shows, that the action was reached.

alias: Verschattung Südseite
description: ""
trigger:
  - type: value
    platform: device
    device_id: a7d7156169ded30a51f215e20f1f8c10
    entity_id: 6ed6a52628b360e693e235cc11ff0336
    domain: sensor
    above: 120
    id: azimut_over_110
  - type: value
    platform: device
    device_id: a7d7156169ded30a51f215e20f1f8c10
    entity_id: 6ed6a52628b360e693e235cc11ff0336
    domain: sensor
    above: 200
    id: azimut_over_210
condition:
  - condition: state
    entity_id: sensor.openweathermap_condition
    state: sunny
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - azimut_over_110
          - condition: state
            entity_id: input_boolean.livingroom_cover_shadow_mode
            state: "off"
        sequence:
          - device_id: 22431c6409bab01448e2ea4c80166498
            domain: cover
            entity_id: da9fc49db104734c571fbc2eac41a289
            type: set_position
            position: 60
          - device_id: 357e912536127fd42db0491e70c71c18
            domain: cover
            entity_id: 92201f3afbba17f9c16e714dea1b70f6
            type: set_position
            position: 40
          - service: input_boolean.turn_on
            data: {}
            target:
              entity_id: input_boolean.livingroom_cover_shadow_mode
      - conditions:
          - condition: trigger
            id:
              - azimut_over_210
          - condition: state
            entity_id: input_boolean.livingroom_cover_shadow_mode
            state: "on"
        sequence:
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id: input_boolean.livingroom_cover_shadow_mode
          - service: cover.open_cover
            metadata: {}
            data: {}
            target:
              label_id: suedseite
mode: single

Entities are part of the label:

I Have no clue why. Maybe a bug concerned the newly introduced label system?

BR
triso

The docs don’t say you can use label_id in the target, so not a bug. Maybe a feature request…

image

Few, if any, of the services docs have been update to include the fact that they support “label_id”… in fact, there are still a number of core integration docs, like Light whose Services section don’t even directly mention the use of target, let alone the ability to use it to target areas, devices, or labels.

1 Like

You’re right. That’s poor, but expected I guess.

Is it possible that this is failing because you’re trying to call cover.open_cover on an input_boolean and an automation?

Can you post the trace json?

Actually, i did not read the docs. I assumed it to be workung, because i used the visual editor to create the automation and ist showed me the option to also choose labels as targets. So it should be a feature already.

@Didgeridrew inspecting the traces further, i saw, that it partly worked only on one cover but i didnt realized it yesterday. And indeed this cover got opened in reality :).
So thats the proof, that the pricinple is working but there semms to be something wrong with the implementation. Maybe an iteration issue?

Find attached the complete trace.

Thanks in advance.
triso

{
  "trace": {
    "last_step": "action/0/choose/1/sequence/1",
    "run_id": "6f2c71eafaf52334db6e8783e8ffa745",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2024-05-16T08:39:13.784408+00:00",
      "finish": "2024-05-16T08:39:13.805712+00:00"
    },
    "domain": "automation",
    "item_id": "1715769836571",
    "trigger": "numeric state of sensor.sun_solar_azimuth",
    "trace": {
      "trigger/1": [
        {
          "path": "trigger/1",
          "timestamp": "2024-05-16T08:39:13.784656+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.verschattung_wohnzimmer",
              "state": "on",
              "attributes": {
                "id": "1715769836571",
                "last_triggered": "2024-05-16T08:07:13.750373+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Verschattung Südseite"
              },
              "last_changed": "2024-05-16T08:37:02.605877+00:00",
              "last_reported": "2024-05-16T08:37:02.605877+00:00",
              "last_updated": "2024-05-16T08:37:02.605877+00:00",
              "context": {
                "id": "01HY08RCGDQV41SRV9TPDHCCRK",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "id": "azimut_over_210",
              "idx": "1",
              "alias": null,
              "platform": "device",
              "entity_id": "sensor.sun_solar_azimuth",
              "below": null,
              "above": 124,
              "from_state": {
                "entity_id": "sensor.sun_solar_azimuth",
                "state": "123.58",
                "attributes": {
                  "state_class": "measurement",
                  "unit_of_measurement": "°",
                  "friendly_name": "Sun Azimut"
                },
                "last_changed": "2024-05-16T08:35:13.771713+00:00",
                "last_reported": "2024-05-16T08:35:13.771713+00:00",
                "last_updated": "2024-05-16T08:35:13.771713+00:00",
                "context": {
                  "id": "01HY08N27BZJ6PTKZ4HR55Q4DW",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "sensor.sun_solar_azimuth",
                "state": "124.74",
                "attributes": {
                  "state_class": "measurement",
                  "unit_of_measurement": "°",
                  "friendly_name": "Sun Azimut"
                },
                "last_changed": "2024-05-16T08:39:13.774118+00:00",
                "last_reported": "2024-05-16T08:39:13.774118+00:00",
                "last_updated": "2024-05-16T08:39:13.774118+00:00",
                "context": {
                  "id": "01HY08WCKE1JJH3RR1WC8K1743",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "description": "numeric state of sensor.sun_solar_azimuth"
            }
          }
        }
      ],
      "condition/0": [
        {
          "path": "condition/0",
          "timestamp": "2024-05-16T08:39:13.784744+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "condition/0/conditions/0": [
        {
          "path": "condition/0/conditions/0",
          "timestamp": "2024-05-16T08:39:13.784804+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "condition/0/conditions/0/entity_id/0": [
        {
          "path": "condition/0/conditions/0/entity_id/0",
          "timestamp": "2024-05-16T08:39:13.784877+00:00",
          "result": {
            "result": false,
            "state": "partlycloudy",
            "wanted_state": "sunny"
          }
        }
      ],
      "condition/0/conditions/1": [
        {
          "path": "condition/0/conditions/1",
          "timestamp": "2024-05-16T08:39:13.785003+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "condition/0/conditions/1/entity_id/0": [
        {
          "path": "condition/0/conditions/1/entity_id/0",
          "timestamp": "2024-05-16T08:39:13.785104+00:00",
          "result": {
            "result": true,
            "state": "partlycloudy",
            "wanted_state": "partlycloudy"
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2024-05-16T08:39:13.785850+00:00",
          "changed_variables": {
            "context": {
              "id": "01HY08WCKR1A52MNWVS8G5SV8E",
              "parent_id": "01HY08WCKE1JJH3RR1WC8K1743",
              "user_id": null
            }
          },
          "result": {
            "choice": 1
          }
        }
      ],
      "action/0/choose/0": [
        {
          "path": "action/0/choose/0",
          "timestamp": "2024-05-16T08:39:13.786529+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/conditions/0",
          "timestamp": "2024-05-16T08:39:13.786603+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/1": [
        {
          "path": "action/0/choose/1",
          "timestamp": "2024-05-16T08:39:13.786731+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/1/conditions/0": [
        {
          "path": "action/0/choose/1/conditions/0",
          "timestamp": "2024-05-16T08:39:13.786792+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/1/conditions/1": [
        {
          "path": "action/0/choose/1/conditions/1",
          "timestamp": "2024-05-16T08:39:13.786866+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/1/conditions/1/entity_id/0": [
        {
          "path": "action/0/choose/1/conditions/1/entity_id/0",
          "timestamp": "2024-05-16T08:39:13.786931+00:00",
          "result": {
            "result": true,
            "state": "on",
            "wanted_state": "on"
          }
        }
      ],
      "action/0/choose/1/sequence/0": [
        {
          "path": "action/0/choose/1/sequence/0",
          "timestamp": "2024-05-16T08:39:13.787316+00:00",
          "result": {
            "params": {
              "domain": "input_boolean",
              "service": "turn_off",
              "service_data": {},
              "target": {
                "entity_id": [
                  "input_boolean.livingroom_cover_shadow_mode"
                ]
              }
            },
            "running_script": false
          }
        }
      ],
      "action/0/choose/1/sequence/1": [
        {
          "path": "action/0/choose/1/sequence/1",
          "timestamp": "2024-05-16T08:39:13.790801+00:00",
          "result": {
            "params": {
              "domain": "cover",
              "service": "open_cover",
              "service_data": {},
              "target": {
                "label_id": [
                  "suedseite"
                ]
              }
            },
            "running_script": false
          }
        }
      ]
    },
    "config": {
      "id": "1715769836571",
      "alias": "Verschattung Südseite",
      "description": "",
      "trigger": [
        {
          "type": "value",
          "platform": "device",
          "device_id": "a7d7156169ded30a51f215e20f1f8c10",
          "entity_id": "6ed6a52628b360e693e235cc11ff0336",
          "domain": "sensor",
          "above": 100,
          "id": "azimut_over_110"
        },
        {
          "type": "value",
          "platform": "device",
          "device_id": "a7d7156169ded30a51f215e20f1f8c10",
          "entity_id": "6ed6a52628b360e693e235cc11ff0336",
          "domain": "sensor",
          "above": 124,
          "id": "azimut_over_210"
        }
      ],
      "condition": [
        {
          "condition": "or",
          "conditions": [
            {
              "condition": "state",
              "entity_id": "sensor.openweathermap_condition",
              "state": "sunny"
            },
            {
              "condition": "state",
              "entity_id": "sensor.openweathermap_condition",
              "state": "partlycloudy"
            }
          ]
        }
      ],
      "action": [
        {
          "choose": [
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": [
                    "azimut_over_110"
                  ]
                },
                {
                  "condition": "state",
                  "entity_id": "input_boolean.livingroom_cover_shadow_mode",
                  "state": "off"
                }
              ],
              "sequence": [
                {
                  "device_id": "22431c6409bab01448e2ea4c80166498",
                  "domain": "cover",
                  "entity_id": "da9fc49db104734c571fbc2eac41a289",
                  "type": "set_position",
                  "position": 60
                },
                {
                  "device_id": "357e912536127fd42db0491e70c71c18",
                  "domain": "cover",
                  "entity_id": "92201f3afbba17f9c16e714dea1b70f6",
                  "type": "set_position",
                  "position": 40
                },
                {
                  "service": "input_boolean.turn_on",
                  "data": {},
                  "target": {
                    "entity_id": "input_boolean.livingroom_cover_shadow_mode"
                  }
                }
              ]
            },
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": [
                    "azimut_over_210"
                  ]
                },
                {
                  "condition": "state",
                  "entity_id": "input_boolean.livingroom_cover_shadow_mode",
                  "state": "on"
                }
              ],
              "sequence": [
                {
                  "service": "input_boolean.turn_off",
                  "data": {},
                  "target": {
                    "entity_id": "input_boolean.livingroom_cover_shadow_mode"
                  }
                },
                {
                  "service": "cover.open_cover",
                  "metadata": {},
                  "data": {},
                  "target": {
                    "label_id": "suedseite"
                  }
                }
              ]
            }
          ]
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01HY08WCKR1A52MNWVS8G5SV8E",
      "parent_id": "01HY08WCKE1JJH3RR1WC8K1743",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Verschattung Südseite",
      "message": "triggered by numeric state of sensor.sun_solar_azimuth",
      "source": "numeric state of sensor.sun_solar_azimuth",
      "entity_id": "automation.verschattung_wohnzimmer",
      "context_id": "01HY08WCKR1A52MNWVS8G5SV8E",
      "when": 1715848753.785299,
      "domain": "automation"
    },
    {
      "when": 1715848753.790233,
      "state": "off",
      "entity_id": "input_boolean.livingroom_cover_shadow_mode",
      "icon": "mdi:sun-angle",
      "context_event_type": "automation_triggered",
      "context_domain": "automation",
      "context_name": "Verschattung Südseite",
      "context_message": "triggered by numeric state of sensor.sun_solar_azimuth",
      "context_source": "numeric state of sensor.sun_solar_azimuth",
      "context_entity_id": "automation.verschattung_wohnzimmer"
    },
    {
      "when": 1715848754.089957,
      "state": "opening",
      "entity_id": "cover.bedroom_cover_window",
      "context_event_type": "automation_triggered",
      "context_domain": "automation",
      "context_name": "Verschattung Südseite",
      "context_message": "triggered by numeric state of sensor.sun_solar_azimuth",
      "context_source": "numeric state of sensor.sun_solar_azimuth",
      "context_entity_id": "automation.verschattung_wohnzimmer"
    }
  ]
}

As @Troon says, you have different types of entity with the same label.

In your screenshot there are three cover entities, one input_boolean and one automation. The service…

          - service: cover.open_cover
            metadata: {}
            data: {}
            target:
              label_id: suedseite

is not going to work on two of them. They are not present in the automation which you say does work.

You can give the same label to a mixture of, say, lights, switches and input_booleans provided you always use the homeassistant.turn_on service, but I don’t think open_cover is ever going to work with the automation entity, is it? :thinking:

1 Like

I understant your point, but i would expect, that HA only hands over the items, which cover.open_cover can work on. In this case only covers. And obviously it does, because one of the three covers is actually reacting.

Other indications, that its intended to work like this:

  • if you want to add labels to the cover.open_cover service in the visual editor, it only shows labels, which point to covers
  • if you have selected a label in the cover.open_cover service in the visual editor and you click on the two arrows shown on the label (<>), then it expands and shows the right three entities

It should work the way you’ve written it. Write up an issue.

worse case…

  target:
    entity_id: "{{ label_entities('suedseite') | select('match', 'cover.') | list }}"
1 Like

Thanks, i will do.