Labels: allow defining in yaml

2024.4 added labels.
Currently labels for entities & automations can be assigned in UI only.
Suggest to add possibility to define & assign labels in yaml.

  1. Defining labels should be possible in different yaml files (splitting config).
  2. Labels defined in yaml & labels defined in UI must be merged.
  3. Labels must be unique.
  4. Entity of any type (i.e. sensors, automations etc) should be allowed to have a label (labels) assigned (out of defined labels) - for instance by using “customize” / “customize_glob”.

My first thought upon reading the release notes. Currently maintaining a bunch of sensors to do with solar inverters and having to prefix the sensor names according to the brand of device, being able to add a ‘label: huawei (or fronius etc)’ in the yaml template/sensor would be so much better.

:+1:t4:

  1. Entity of any type (i.e. sensors, automations etc) should be allowed to have a label (labels) assigned (out of defined labels) - for instance by using “customize” / “customize_glob”.

As someone who prefers doing it the hard way (HA Core, as much of the configuration in YAML as possible) I second this reques wholehartedly.

Please allow us to define Floors, Labels and Categories in YAML files and assign them in YAML files as well (preferably this will include Locations)

With regards to point 4 in the original post: Why not add a floors/labels/categories attribute that accepts a list of floors/labels/categories? (and preferably locations as well…)

3 Likes
  1. Probably a new entry should be added:

image

1 Like

All of my automations are defined in yaml. Please allow us to define labels in yaml. thanks

5 Likes

I’d love to replace some or all of my groups with labels, but for that to be feasible it really would be necessary to have a way (service) to dynamically assign/remove entities to/from labels - like you can with groups …

1 Like

The new labels are really great, no doubt. Big applause. :ok_hand:

I think a label is by definition a property of an item (automation, entity, whatever…).

But when having a lot of configurations in YAML I now have to define some/most of the properties in YAML but others in UI.
Neither looking at the YAML code nor looking in the UI gives me the whole picture.

Personally I would like to define labels in YAML too, just to keep everything together.

1 Like

Yep, I wish YAML wasn’t a second class citizen.

5 Likes

not that I would have anything against the FR, but we can add labels on yaml defined automations? (as OP states btw)
All of my automations are yaml too, no issue adding UI labels

I know that I can do it in the UI, the request is to assign the labels in yaml. Silly to have to go back and forth between yaml and UI.

1 Like

sorry, I misunderstood your request. nevermind then…

the use and flexibility of the Ui for labels is rather magical though, and will never be approached by what ever we might be able to do in our Yaml.

Changing the labels on the fly, attaching them to other entities and what have you, its all a snap of the finger in the UI.

Defining a label in could probably be done, but the UI truly is the place to be in this case (and thats coming from a real yaml user…)

1 Like

That would be the best: experiment in the UI, see the changes in YAML.

I don’t want YAML just for the sake of typing “code” instead of clicking – I like YAML (one of the reasons) as it is a simple text file format that I can track with version control system (git). Not possible with GUI.

2 Likes

Yeah, this is really needed. I have lots of yaml defined automations without a unique id, provided by a hacs integration, and after assigning labels to all automations these have to all be excluded. Makes it not very useful if I can’t completely label all of them.

2 Likes

somehow that seems to be much more of an issue for your problem, than defining labels in yaml.

why not add id’s to those automations, and be completely editable in the UI. It’s a 1 time effort, and you’ll enjoy it the rest of the time using HA

Adding ids to automations is not same as migrating automations from yaml to UI.

(unrelated to the topic) I would suggest you to add ids to automations. This will give you a possibility to see traces, might be useful for debugging. Do not migrate automation to UI, this is for traces only.
And you will be able to add a label then - for testing at least.
I have not added any labels yet since still using my own “labels” (kept as attributes). Will probably add labels when a corr. support will be added for yaml.

This post seems relevant: 2024.4: Organize all the things! - #444 by KennethLavrsen.

For me, I’d prefer the ability to define labels in YAML.

I have unique IDs for all of them for the sole purpose of traces.

I don’t want to migrate my automations, since I’ll lose comments (vital, and no, I’m not hacking it via descriptions) and I’ll lose my organisation via packages.

1 Like

I seem to be in the exact situation as you are with my Yaml config. All packages, important comments and links to elsewhere, nicely in Yaml, which we can find blindfolded). All automations and scripts in yaml.

Given the current automation editor, my thoughts on my yaml config for those integrations won’t change in the near future.

And yet, there is no reason for me to want to configure labels in Yaml. Especially since you have unique_id’s you can edit everything in the UI including the new labels.

Because with that you get the ultimate ease of being able to edit/change a label, and it being applied everywhere automatically by the system. (you will change them a lot, so having this automated is a huge asset)

If you’d set labels in yaml and add them per entity, you would have to edit the label itself, and all occurrences of that particular label yourself, which ultimately is rather error prone (talking to myself here… )

Why not embrace both ?

1 Like

I might’ve misunderstood something about labels (and categories) then: It seemed like when a label or category gets added, the automation needs to be migrated. Is that not the case?

no, no migration required.
the only thing required is to have a unique_id to be able to edit in the UI.

Category is for organizing in the Tables (and can not be referenced by the backend logic in automations/templates etc),

Labels are built for that purpose mainly,

though one could also say you can organize the tables with them: