Conversation
| "--color": !this.badge.state_color ? this.badge.color : undefined, | ||
| "--background-color": this.badge.background_color, | ||
| "background-image": clsImageOnly | ||
| ? `url(${this.hass.hassUrl(this.badge.image)})` |
There was a problem hiding this comment.
This could be a CSS injection risk. ha-entity-marker.ts already does this so may not be a real problem though. Have to think about it
There was a problem hiding this comment.
State-badge uses same this.hass.hassUrl() thing... Imho the risk should be minimized in the hassUrl function.
|
How does it looks without zoom? All the screenshot are zoomed. Can you put a full map screenshot so we can have a global overview on this PR? |
|
First renamed |
|
Hi @ildar170975, We discussed this and will close it because:
Sorry and thanks for the proposal! Best |
We already have a “label_mode” feature for map markers to show info - then what is a big deal with showing additional info in additional badges? |
I am sorry that you feel like that. But it's not true. As I said to you we discussed it. So we as a group of 5 people looked into your PR and decided that this badge doesn't add additional value to the marker and it's way too small. |
|
Not so small for a big screen. And you can always increase the marker (and a badge) with a theme variable. And there will be media query conditions as was described. As for additional info. There is such a thing like “secondary info”. Here the badge is same. Why do we have additional secondary info? Let’s propose users not have it. |
|
Thanks for the additional context and for sharing your perspective. We understand your reasoning and appreciate the effort you put into this PR. Our decision stands, but we wish you all the best with your custom card! |

Breaking change
Proposed change
Adds an optional badge for a marker on a Map.
Examples are below.
UI for setting the new options will provided later.
Options of a badge (all are optional):
entity- entity_id to be processed;label_mode– can belabel,state,attribute,icon,image;label: string- only processed iflabel_mode: label; used to display a state/attribute value or any text;attribute– chooses an attribute; only processed iflabel_mode: attribute;unit– sets a unit for an attribute value; only processed iflabel_mode: attribute;image– overrides an entity picture if anentityis defined; or set a picture if noentitydefined;icon– overrides an entity icon if anentityis defined; or set an icon if noentitydefined;color- affects label & icon;background_color– as it says;state_color– similar to other cards; only processed for domains which support colors;hide_unit(true/false) – omit a unit for compactness; applied both to a state & attribute.Notes:
badgecannot be not applied to a zone.entityis provided).label_mode: attributew/o definingentityorattributeoptions) causes displaying a standardmdi:alerticon.border-radius: 0) with an offset = ¼ of a badge size:hide_unitoption (both for a state & attribute).unitoption of a badge is only processed forlabel_mode: attributecase; intended to set a unit for unitless attributes (also, can be used to add an additional suffix if an attribute does have a unit).borderColorproperty is “inherited” from a marker (affects on aborder-colorcss property of a badge).hide_unitoption is set. It is possible to set own font-size by a new CSS variable--ha-marker-badge-font-size(overrides that automatic increasing, thus same font-size will be used whetherhide_unitis set or not).--ha-marker-badge-border-radiuscan be used; default radius is50%.Next steps:
Possible improvements:
ha-svg-iconelement for erroneous config withmdi:alerticon - like astate-badgeelement – with samefce588color. Perhaps this color should be defined somewhere as a variable.Possible use-cases are shown in examples below, like:
Examples:
Minimal config:
If an entity has
entity_picture:Show a text label (
entitymay be NOT defined – unless you need to get an additional logic & info in more-info) – could be a name of a device / vehicle / person / pet / ...:Show an icon (
entitymay be NOT defined – unless you need to get an additional logic & info in more-info) – could be an icon of a device / vehicle / person / pet / ...:Show an icon for an entity with
entity_picture- instead of that picture:And the icon can be customized:
Show an image (
entitymay be NOT defined – unless you need to get an additional logic & info in more-info) – could be an image of a device / vehicle / person / pet / ...:Show a state (with or w/o a unit) – could be a battery_level / speed / ...:
Show an attribute (with or w/o a unit) (just a synthetic example, could be anything else of course):
Example for
geo_locationsources:With
state_colorset:With
colorset to colorize an icon & a label:With
background_colordefined:A wrong config causes an
mdi:alert:Screenshots
Type of change
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed:
To help with the load of incoming pull requests: