-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Map card: add prefix & suffix for "label_mode: attribute" #25033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Map card: add prefix & suffix for "label_mode: attribute" #25033
Conversation
We don't need to add an option for that. We can render attribute with the right unit. Attribute units can be added to this file : frontend/src/data/entity_attributes.ts Line 41 in 1bba103
For example we can add this to have unit for latitude, longitude, battery and gps_accuracy : person: {
gps_accuracy: "m",
battery: "%",
latitude: "°",
longitude: "°",
},
device_tracker: {
gps_accuracy: "m",
battery: "%",
latitude: "°",
longitude: "°",
} For prefix, I don't see other use-cases so I would not put it as an option for only this case. |
But what if the entity is a template sensor?
We have prefix/suffix in Entities card, so I wanted to make similar. |
The template sensor can provide its own unit of measurement so it can be displayed here. The unit for entity card was introduced 5 years ago when we didn't have unit translations and unit provided by the backend. Also, we are trying to avoid using too many attribute for entity to be more device centric. For example, the battery level attribute for vacuum has been moved to its own entity. |
For a state, not for an attribute.
But still many integrations have attributes. |
Can you provide examples provided by HA integration? It may be solved by automatically by adding unit for the attribute. |
GDACS, transport schedule integrations, many of them.
Good, but you cannot provide ways for template sensors. |
Which attribute GDACS provide that require a suffix or prefix? |
Sensors of HACS have a variable set of attributes - perhaps dependently on a particular event, could be smth like "water height", "population loss" etc. For these attributes a user may want to have a unit (in general - prefix/suffix). Also, there are PLENTY of integrations, not sure that frontend should oblige all of them to have hardcoded units. I wonder if it is possible to combine methods: allow showing hardcoded uoms (if they are provided; also - NOT use it if not needed) OR use own suffixes. |
We are generally skeptical of new options and css variables because we will likely be stuck with them forever. |
So far attributes are supported in entities, so why not letting users to add them on cards. As for "we will likely be stuck with them forever" - recent changes in the world should encourage people to stop thinking that everything can last for ages. Everything may change. Anyway, I am not insisting on this PR. There are alternative custom map cards which can be used for such scenarios. |
I hear you. My point was not disallowing attributes. Just that we shouldn't support them as much as entity state. We allow using attributes everywhere but if you want the full experience, you have to move the data to an entity. |
Agreed definitely!
So, I may do:
|
Converting to draft. Will continue in a week when hopefully be home again. |
One more thing. Instead of |
Agree, will use a “unit” ! Will continue in a week I hope. |
Breaking change
Proposed change
Added prefix & suffix for

label_mode: attribute
on Map card.Also, introduced 2 new CSS theme vars
--ha-marker-prefix-margin
,--ha-marker-suffix-margin
to manage margins between a prefix, suffix & attribute's value.Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: