mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Map card: add prefix & suffix for "label_mode: attribute" (#25033)
* added prefix & suffix * added prefix & suffix * added prefix & suffix * added prefix & suffix * added prefix & suffix * remove prefix, rename suffix -> unit * remove prefix, rename suffix -> unit * remove prefix, rename suffix -> unit * remove prefix, rename suffix -> unit * remove prefix, rename suffix -> unit
This commit is contained in:
parent
67003d6fd1
commit
6730d08b85
@ -12,6 +12,8 @@ class HaEntityMarker extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: "entity-name" }) public entityName?: string;
|
@property({ attribute: "entity-name" }) public entityName?: string;
|
||||||
|
|
||||||
|
@property({ attribute: "entity-unit" }) public entityUnit?: string;
|
||||||
|
|
||||||
@property({ attribute: "entity-picture" }) public entityPicture?: string;
|
@property({ attribute: "entity-picture" }) public entityPicture?: string;
|
||||||
|
|
||||||
@property({ attribute: "entity-color" }) public entityColor?: string;
|
@property({ attribute: "entity-color" }) public entityColor?: string;
|
||||||
@ -37,7 +39,16 @@ class HaEntityMarker extends LitElement {
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.stateObj=${this.hass?.states[this.entityId]}
|
.stateObj=${this.hass?.states[this.entityId]}
|
||||||
></ha-state-icon>`
|
></ha-state-icon>`
|
||||||
: this.entityName}
|
: !this.entityUnit
|
||||||
|
? this.entityName
|
||||||
|
: html`
|
||||||
|
${this.entityName}
|
||||||
|
<span
|
||||||
|
class="unit"
|
||||||
|
style="display: ${this.entityUnit ? "initial" : "none"}"
|
||||||
|
>${this.entityUnit}</span
|
||||||
|
>
|
||||||
|
`}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@ -72,6 +83,9 @@ class HaEntityMarker extends LitElement {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
.unit {
|
||||||
|
margin-left: 2px;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ export interface HaMapEntity {
|
|||||||
color: string;
|
color: string;
|
||||||
label_mode?: "name" | "state" | "attribute" | "icon";
|
label_mode?: "name" | "state" | "attribute" | "icon";
|
||||||
attribute?: string;
|
attribute?: string;
|
||||||
|
unit?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
focus?: boolean;
|
focus?: boolean;
|
||||||
}
|
}
|
||||||
@ -549,6 +550,12 @@ export class HaMap extends ReactiveElement {
|
|||||||
typeof entity !== "string" && entity.label_mode === "icon";
|
typeof entity !== "string" && entity.label_mode === "icon";
|
||||||
entityMarker.entityId = getEntityId(entity);
|
entityMarker.entityId = getEntityId(entity);
|
||||||
entityMarker.entityName = entityName;
|
entityMarker.entityName = entityName;
|
||||||
|
entityMarker.entityUnit =
|
||||||
|
typeof entity !== "string" &&
|
||||||
|
entity.unit &&
|
||||||
|
entity.label_mode === "attribute"
|
||||||
|
? entity.unit
|
||||||
|
: "";
|
||||||
entityMarker.entityPicture =
|
entityMarker.entityPicture =
|
||||||
entityPicture && (typeof entity === "string" || !entity.label_mode)
|
entityPicture && (typeof entity === "string" || !entity.label_mode)
|
||||||
? this.hass.hassUrl(entityPicture)
|
? this.hass.hassUrl(entityPicture)
|
||||||
|
@ -45,6 +45,7 @@ export const DEFAULT_ZOOM = 14;
|
|||||||
interface MapEntityConfig extends EntityConfig {
|
interface MapEntityConfig extends EntityConfig {
|
||||||
label_mode?: "state" | "attribute" | "name";
|
label_mode?: "state" | "attribute" | "name";
|
||||||
attribute?: string;
|
attribute?: string;
|
||||||
|
unit?: string;
|
||||||
focus?: boolean;
|
focus?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ interface GeoEntity {
|
|||||||
entity_id: string;
|
entity_id: string;
|
||||||
label_mode?: "state" | "attribute" | "name" | "icon";
|
label_mode?: "state" | "attribute" | "name" | "icon";
|
||||||
attribute?: string;
|
attribute?: string;
|
||||||
|
unit?: string;
|
||||||
focus: boolean;
|
focus: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,6 +432,7 @@ class HuiMapCard extends LitElement implements LovelaceCard {
|
|||||||
entity_id: stateObj.entity_id,
|
entity_id: stateObj.entity_id,
|
||||||
label_mode: sourceObj?.label_mode ?? allSource?.label_mode,
|
label_mode: sourceObj?.label_mode ?? allSource?.label_mode,
|
||||||
attribute: sourceObj?.attribute ?? allSource?.attribute,
|
attribute: sourceObj?.attribute ?? allSource?.attribute,
|
||||||
|
unit: sourceObj?.unit ?? allSource?.unit,
|
||||||
focus: sourceObj
|
focus: sourceObj
|
||||||
? (sourceObj.focus ?? true)
|
? (sourceObj.focus ?? true)
|
||||||
: (allSource?.focus ?? true),
|
: (allSource?.focus ?? true),
|
||||||
@ -446,6 +449,7 @@ class HuiMapCard extends LitElement implements LovelaceCard {
|
|||||||
color: this._getColor(entityConf.entity),
|
color: this._getColor(entityConf.entity),
|
||||||
label_mode: entityConf.label_mode,
|
label_mode: entityConf.label_mode,
|
||||||
attribute: entityConf.attribute,
|
attribute: entityConf.attribute,
|
||||||
|
unit: entityConf.unit,
|
||||||
focus: entityConf.focus,
|
focus: entityConf.focus,
|
||||||
name: entityConf.name,
|
name: entityConf.name,
|
||||||
})),
|
})),
|
||||||
|
@ -323,6 +323,7 @@ interface GeoLocationSourceConfig {
|
|||||||
source: string;
|
source: string;
|
||||||
label_mode?: "name" | "state" | "attribute" | "icon";
|
label_mode?: "name" | "state" | "attribute" | "icon";
|
||||||
attribute?: string;
|
attribute?: string;
|
||||||
|
unit?: string;
|
||||||
focus?: boolean;
|
focus?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ export const mapEntitiesConfigStruct = union([
|
|||||||
entity: string(),
|
entity: string(),
|
||||||
label_mode: optional(string()),
|
label_mode: optional(string()),
|
||||||
attribute: optional(string()),
|
attribute: optional(string()),
|
||||||
|
unit: optional(string()),
|
||||||
focus: optional(boolean()),
|
focus: optional(boolean()),
|
||||||
name: optional(string()),
|
name: optional(string()),
|
||||||
}),
|
}),
|
||||||
@ -51,6 +52,7 @@ const geoSourcesConfigStruct = union([
|
|||||||
source: string(),
|
source: string(),
|
||||||
label_mode: optional(string()),
|
label_mode: optional(string()),
|
||||||
attribute: optional(string()),
|
attribute: optional(string()),
|
||||||
|
unit: optional(string()),
|
||||||
focus: optional(boolean()),
|
focus: optional(boolean()),
|
||||||
}),
|
}),
|
||||||
string(),
|
string(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user