#Could not figure out how to use label_id with turn_off

1 messages · Page 1 of 1 (latest)

iron brook
#

Hi folks. I could not figure out why the following won't work: If I use

action: homeassistant.turn_off
metadata: {}
data: {}
target:
  entity_id:
    - switch.adalbert_3_internet_access
    - switch.alfhildr_internet_access
    - switch.wohnzimmer_internet_access
    - switch.sarinasipad_internet_access
    - switch.josiasipad_internet_access

everything works fine. But the shorter form

action: homeassistant.turn_off
metadata: {}
data: {}
target:
  label_id: kinder_internetzugang

does not work. It has no impact at all. But when I test the template

{{ label_entities('kinder_internetzugang') }}

it brings the list

[
  "switch.adalbert_3_internet_access",
  "switch.alfhildr_internet_access",
  "switch.josiasipad_internet_access",
  "switch.sarinasipad_internet_access",
  "switch.wohnzimmer_internet_access"
]

Could you please help me with that? Thank you very much.

brave acorn
#

Are you sure that's actually the label id? Did you maybe rename it? The label id will still be based on the old name then.
You can verify by selecting it in an action in developer tools > action in GUI mode, and then look at the YAML

iron brook
#

Yes, I selected it in GUI mode to be sure and tested it in Developer Tools > Template as I described above.

brave acorn
#

the template accepts both label names and label ids, that's why I asked. If the label name is kinder_internetzugang but the label id is children_internet_access because you renamed it afterwards, the template will work, but the action not

#

I tested the action with a label of my own, and it worked fine

#

Not sure why it doesn't for you, but you could use the template in your action as well

#
action: homeassistant.turn_off
target:
  entity_id: "{{ label_entities('kinder_internetzugang') }}"