Ability to show map icons for geolocation sources (#23247)

This commit is contained in:
karwosts
2024-12-21 07:29:53 -08:00
committed by GitHub
parent 31e85836f0
commit 4de8b562bd
5 changed files with 33 additions and 18 deletions

View File

@@ -1,9 +1,13 @@
import { LitElement, html, css } from "lit";
import { property } from "lit/decorators";
import { styleMap } from "lit/directives/style-map";
import type { HomeAssistant } from "../../types";
import { fireEvent } from "../../common/dom/fire_event";
import "../ha-state-icon";
class HaEntityMarker extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ attribute: "entity-id" }) public entityId?: string;
@property({ attribute: "entity-name" }) public entityName?: string;
@@ -12,6 +16,8 @@ class HaEntityMarker extends LitElement {
@property({ attribute: "entity-color" }) public entityColor?: string;
@property({ attribute: "show-icon", type: Boolean }) public showIcon = false;
protected render() {
return html`
<div
@@ -26,7 +32,12 @@ class HaEntityMarker extends LitElement {
"background-image": `url(${this.entityPicture})`,
})}
></div>`
: this.entityName}
: this.showIcon && this.entityId
? html`<ha-state-icon
.hass=${this.hass}
.stateObj=${this.hass?.states[this.entityId]}
></ha-state-icon>`
: this.entityName}
</div>
`;
}