diff --git a/src/components/ha-state-icon.ts b/src/components/ha-state-icon.ts index 062da216375d..2589dc318f81 100644 --- a/src/components/ha-state-icon.ts +++ b/src/components/ha-state-icon.ts @@ -14,6 +14,8 @@ export class HaStateIcon extends LitElement { @property({ attribute: false }) public stateObj?: HassEntity; + @property({ attribute: false }) public stateValue?: string; + @property() public icon?: string; protected render() { @@ -30,12 +32,14 @@ export class HaStateIcon extends LitElement { if (!this.hass) { return this._renderFallback(); } - const icon = entityIcon(this.hass, this.stateObj).then((icn) => { - if (icn) { - return html``; + const icon = entityIcon(this.hass, this.stateObj, this.stateValue).then( + (icn) => { + if (icn) { + return html``; + } + return this._renderFallback(); } - return this._renderFallback(); - }); + ); return html`${until(icon)}`; } diff --git a/src/components/tile/ha-tile-badge.ts b/src/components/tile/ha-tile-badge.ts index dea713e069f2..33aa85fce4d0 100644 --- a/src/components/tile/ha-tile-badge.ts +++ b/src/components/tile/ha-tile-badge.ts @@ -1,19 +1,13 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; -import { customElement, property } from "lit/decorators"; +import { customElement } from "lit/decorators"; import "../ha-icon"; @customElement("ha-tile-badge") export class HaTileBadge extends LitElement { - @property() public iconPath?: string; - - @property() public icon?: string; - protected render(): TemplateResult { return html`
- ${this.icon - ? html`` - : html``} +
`; } @@ -36,8 +30,7 @@ export class HaTileBadge extends LitElement { background-color: var(--tile-badge-background-color); transition: background-color 280ms ease-in-out; } - .badge ha-icon, - .badge ha-svg-icon { + .badge ::slotted(*) { color: var(--tile-badge-icon-color); } `; diff --git a/src/components/tile/ha-tile-icon.ts b/src/components/tile/ha-tile-icon.ts index 5bf889575f53..f5ebe8863c52 100644 --- a/src/components/tile/ha-tile-icon.ts +++ b/src/components/tile/ha-tile-icon.ts @@ -1,20 +1,14 @@ -import { CSSResultGroup, html, css, LitElement, TemplateResult } from "lit"; -import { customElement, property } from "lit/decorators"; +import { CSSResultGroup, LitElement, TemplateResult, css, html } from "lit"; +import { customElement } from "lit/decorators"; import "../ha-icon"; import "../ha-svg-icon"; @customElement("ha-tile-icon") export class HaTileIcon extends LitElement { - @property() public iconPath?: string; - - @property() public icon?: string; - protected render(): TemplateResult { return html`
- ${this.icon - ? html`` - : html``} +
`; } @@ -47,8 +41,7 @@ export class HaTileIcon extends LitElement { transition: color 180ms ease-in-out; overflow: hidden; } - .shape ha-icon, - .shape ha-svg-icon { + .shape ::slotted(*) { display: flex; color: var(--tile-icon-color); transition: color 180ms ease-in-out; diff --git a/src/data/icons.ts b/src/data/icons.ts index 544ce8f25d5a..009723d67fa8 100644 --- a/src/data/icons.ts +++ b/src/data/icons.ts @@ -71,10 +71,15 @@ export const getComponentIcons = async ( return resources.entity_component.then((res) => res[domain]); }; -export const entityIcon = async (hass: HomeAssistant, state: HassEntity) => { +export const entityIcon = async ( + hass: HomeAssistant, + state: HassEntity, + stateValue?: string +) => { let icon: string | undefined; const domain = computeStateDomain(state); const entity = hass.entities?.[state.entity_id]; + const value = stateValue ?? state.state; if (entity?.icon) { return entity.icon; } @@ -82,18 +87,19 @@ export const entityIcon = async (hass: HomeAssistant, state: HassEntity) => { const platformIcons = await getPlatformIcons(hass, entity.platform); if (platformIcons) { icon = - platformIcons[domain]?.[entity.translation_key]?.state?.[state.state] || + platformIcons[domain]?.[entity.translation_key]?.state?.[value] || platformIcons[domain]?.[entity.translation_key]?.default; } } if (!icon) { const entityComponentIcons = await getComponentIcons(hass, domain); + if (entityComponentIcons) { icon = entityComponentIcons[state.attributes.device_class || "_"]?.state?.[ - state.state + value ] || - entityComponentIcons._?.state?.[state.state] || + entityComponentIcons._?.state?.[value] || entityComponentIcons[state.attributes.device_class || "_"]?.default || entityComponentIcons._?.default; } @@ -110,13 +116,14 @@ export const attributeIcon = async ( let icon: string | undefined; const domain = computeStateDomain(state); const entity = hass.entities?.[state.entity_id]; + const value = attributeValue ?? state.attributes[attribute]; if (entity?.translation_key && entity.platform) { const platformIcons = await getPlatformIcons(hass, entity.platform); if (platformIcons) { icon = platformIcons[domain]?.[entity.translation_key]?.state_attributes?.[ attribute - ]?.state?.[attributeValue || state.attributes[attribute]]; + ]?.state?.[value]; } } if (!icon) { @@ -124,12 +131,8 @@ export const attributeIcon = async ( if (entityComponentIcons) { icon = entityComponentIcons[state.attributes.device_class || "_"] - .state_attributes?.[attribute]?.state?.[ - attributeValue || state.attributes[attribute] - ] || - entityComponentIcons._.state_attributes?.[attribute]?.state?.[ - attributeValue || state.attributes[attribute] - ]; + .state_attributes?.[attribute]?.state?.[value] || + entityComponentIcons._.state_attributes?.[attribute]?.state?.[value]; } } return icon; diff --git a/src/dialogs/more-info/controls/more-info-alarm_control_panel.ts b/src/dialogs/more-info/controls/more-info-alarm_control_panel.ts index 53cd1ac08ef5..bfc39a2ddc49 100644 --- a/src/dialogs/more-info/controls/more-info-alarm_control_panel.ts +++ b/src/dialogs/more-info/controls/more-info-alarm_control_panel.ts @@ -2,9 +2,9 @@ import { mdiShieldOff } from "@mdi/js"; import { css, CSSResultGroup, html, LitElement, nothing } from "lit"; import { customElement, property } from "lit/decorators"; import { styleMap } from "lit/directives/style-map"; -import { domainIcon } from "../../../common/entity/domain_icon"; import { stateColorCss } from "../../../common/entity/state_color"; import "../../../components/ha-outlined-button"; +import "../../../components/ha-state-icon"; import { AlarmControlPanelEntity } from "../../../data/alarm_control_panel"; import "../../../state-control/alarm_control_panel/ha-state-control-alarm_control_panel-modes"; import type { HomeAssistant } from "../../../types"; @@ -59,9 +59,8 @@ class MoreInfoAlarmControlPanel extends LitElement {
- + +
${this.hass.localize("ui.card.alarm_control_panel.disarm")} diff --git a/src/dialogs/more-info/controls/more-info-lock.ts b/src/dialogs/more-info/controls/more-info-lock.ts index fb5815cc5208..9af77fd128bf 100644 --- a/src/dialogs/more-info/controls/more-info-lock.ts +++ b/src/dialogs/more-info/controls/more-info-lock.ts @@ -2,11 +2,11 @@ import { mdiDoorOpen, mdiLock, mdiLockOff } from "@mdi/js"; import { CSSResultGroup, LitElement, css, html, nothing } from "lit"; import { customElement, property } from "lit/decorators"; import { styleMap } from "lit/directives/style-map"; -import { domainIcon } from "../../../common/entity/domain_icon"; import { stateColorCss } from "../../../common/entity/state_color"; import { supportsFeature } from "../../../common/entity/supports-feature"; import "../../../components/ha-attributes"; import "../../../components/ha-outlined-icon-button"; +import "../../../components/ha-state-icon"; import { UNAVAILABLE } from "../../../data/entity"; import { LockEntity, @@ -62,9 +62,10 @@ class MoreInfoLock extends LitElement {
- +
` diff --git a/src/panels/lovelace/cards/hui-area-card.ts b/src/panels/lovelace/cards/hui-area-card.ts index 5a455a9f6c24..3ceb943ebeec 100644 --- a/src/panels/lovelace/cards/hui-area-card.ts +++ b/src/panels/lovelace/cards/hui-area-card.ts @@ -1,5 +1,7 @@ import "@material/mwc-ripple"; import { + mdiFan, + mdiFanOff, mdiLightbulbMultiple, mdiLightbulbMultipleOff, mdiRun, @@ -9,30 +11,30 @@ import { } from "@mdi/js"; import type { HassEntity, UnsubscribeFunc } from "home-assistant-js-websocket"; import { - css, CSSResultGroup, - html, LitElement, PropertyValues, TemplateResult, + css, + html, nothing, } from "lit"; import { customElement, property, state } from "lit/decorators"; import { classMap } from "lit/directives/class-map"; import { styleMap } from "lit/directives/style-map"; import memoizeOne from "memoize-one"; -import { STATES_OFF, FIXED_DEVICE_CLASS_ICONS } from "../../../common/const"; +import { FIXED_DEVICE_CLASS_ICONS, STATES_OFF } from "../../../common/const"; import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element"; -import { computeDomain } from "../../../common/entity/compute_domain"; import { binarySensorIcon } from "../../../common/entity/binary_sensor_icon"; -import { domainIcon } from "../../../common/entity/domain_icon"; +import { computeDomain } from "../../../common/entity/compute_domain"; import { navigate } from "../../../common/navigate"; import { formatNumber, isNumericState, } from "../../../common/number/format_number"; -import { subscribeOne } from "../../../common/util/subscribe-one"; +import { blankBeforeUnit } from "../../../common/translations/blank_before_unit"; import parseAspectRatio from "../../../common/util/parse-aspect-ratio"; +import { subscribeOne } from "../../../common/util/subscribe-one"; import "../../../components/ha-card"; import "../../../components/ha-icon-button"; import "../../../components/ha-svg-icon"; @@ -56,7 +58,6 @@ import "../components/hui-image"; import "../components/hui-warning"; import { LovelaceCard, LovelaceCardEditor } from "../types"; import { AreaCardConfig } from "./types"; -import { blankBeforeUnit } from "../../../common/translations/blank_before_unit"; export const DEFAULT_ASPECT_RATIO = "16:9"; @@ -76,7 +77,7 @@ export const DEVICE_CLASSES = { const DOMAIN_ICONS = { light: { on: mdiLightbulbMultiple, off: mdiLightbulbMultipleOff }, switch: { on: mdiToggleSwitch, off: mdiToggleSwitchOff }, - fan: { on: domainIcon("fan"), off: domainIcon("fan") }, + fan: { on: mdiFan, off: mdiFanOff }, binary_sensor: { motion: mdiRun, moisture: mdiWaterAlert, diff --git a/src/panels/lovelace/cards/hui-tile-card.ts b/src/panels/lovelace/cards/hui-tile-card.ts index 70d3d13063a3..e400e147ce55 100644 --- a/src/panels/lovelace/cards/hui-tile-card.ts +++ b/src/panels/lovelace/cards/hui-tile-card.ts @@ -28,8 +28,9 @@ import { DOMAINS_TOGGLE } from "../../../common/const"; import { computeDomain } from "../../../common/entity/compute_domain"; import { stateActive } from "../../../common/entity/state_active"; import { stateColorCss } from "../../../common/entity/state_color"; -import { stateIconPath } from "../../../common/entity/state_icon_path"; import "../../../components/ha-card"; +import "../../../components/ha-state-icon"; +import "../../../components/ha-svg-icon"; import "../../../components/tile/ha-tile-badge"; import "../../../components/tile/ha-tile-icon"; import "../../../components/tile/ha-tile-image"; @@ -48,7 +49,7 @@ import { handleAction } from "../common/handle-action"; import { hasAction } from "../common/has-action"; import "../components/hui-timestamp-display"; import type { LovelaceCard, LovelaceCardEditor } from "../types"; -import { computeTileBadge } from "./tile/badges/tile-badge"; +import { renderTileBadge } from "./tile/badges/tile-badge"; import type { ThermostatCardConfig, TileCardConfig } from "./types"; const TIMESTAMP_STATE_DOMAINS = ["button", "input_button", "scene"]; @@ -341,17 +342,14 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
- - + + + + + +
@@ -360,9 +358,6 @@ export class HuiTileCard extends LitElement implements LovelaceCard { `; } - const icon = this._config.icon || stateObj.attributes.icon; - const iconPath = stateIconPath(stateObj); - const name = this._config.name || stateObj.attributes.friendly_name; const localizedState = this._config.hide_state @@ -382,7 +377,6 @@ export class HuiTileCard extends LitElement implements LovelaceCard { const imageUrl = this._config.show_entity_picture ? this._getImageUrl(stateObj) : undefined; - const badge = computeTileBadge(stateObj, this.hass); return html` @@ -420,7 +414,6 @@ export class HuiTileCard extends LitElement implements LovelaceCard { ? html` ` @@ -428,27 +421,18 @@ export class HuiTileCard extends LitElement implements LovelaceCard { + > + + `} - ${badge - ? html` - - ` - : nothing} + ${renderTileBadge(stateObj, this.hass)}
@@ -516,7 +500,7 @@ export class HuiTileCard extends LitElement implements LovelaceCard { margin-inline-start: initial; margin-inline-end: initial; } - .vertical .info { + .vertical ha-tile-info { width: 100%; } .icon-container { @@ -528,14 +512,15 @@ export class HuiTileCard extends LitElement implements LovelaceCard { direction: var(--direction); transition: transform 180ms ease-in-out; } - .icon-container .icon { + .icon-container ha-tile-icon, + .icon-container ha-tile-image { --tile-icon-color: var(--tile-color); user-select: none; -ms-user-select: none; -webkit-user-select: none; -moz-user-select: none; } - .icon-container .badge { + .icon-container ha-tile-badge { position: absolute; top: -3px; right: -3px; @@ -544,7 +529,7 @@ export class HuiTileCard extends LitElement implements LovelaceCard { .icon-container[role="button"]:active { transform: scale(1.2); } - .info { + ha-tile-info { position: relative; padding: 12px; flex: 1; @@ -564,6 +549,10 @@ export class HuiTileCard extends LitElement implements LovelaceCard { animation: pulse 1s infinite; } + ha-tile-badge.not-found { + --tile-badge-background-color: var(--red-color); + } + @keyframes pulse { 0% { opacity: 1; diff --git a/src/panels/lovelace/cards/tile/badges/tile-badge-climate.ts b/src/panels/lovelace/cards/tile/badges/tile-badge-climate.ts index a00d773e5674..ed75266f7475 100644 --- a/src/panels/lovelace/cards/tile/badges/tile-badge-climate.ts +++ b/src/panels/lovelace/cards/tile/badges/tile-badge-climate.ts @@ -1,20 +1,36 @@ +import { html, nothing } from "lit"; +import { styleMap } from "lit/directives/style-map"; import { stateColorCss } from "../../../../../common/entity/state_color"; +import "../../../../../components/ha-attribute-icon"; +import "../../../../../components/tile/ha-tile-badge"; import { - CLIMATE_HVAC_ACTION_ICONS, CLIMATE_HVAC_ACTION_TO_MODE, ClimateEntity, } from "../../../../../data/climate"; -import { ComputeBadgeFunction } from "./tile-badge"; +import { RenderBadgeFunction } from "./tile-badge"; -export const computeClimateBadge: ComputeBadgeFunction = (stateObj) => { +export const renderClimateBadge: RenderBadgeFunction = (stateObj, hass) => { const hvacAction = (stateObj as ClimateEntity).attributes.hvac_action; if (!hvacAction || hvacAction === "off") { - return undefined; + return nothing; } - return { - iconPath: CLIMATE_HVAC_ACTION_ICONS[hvacAction], - color: stateColorCss(stateObj, CLIMATE_HVAC_ACTION_TO_MODE[hvacAction]), - }; + return html` + + + + + `; }; diff --git a/src/panels/lovelace/cards/tile/badges/tile-badge-humidifier.ts b/src/panels/lovelace/cards/tile/badges/tile-badge-humidifier.ts index 709f4e7c68d5..4ca246c02c9d 100644 --- a/src/panels/lovelace/cards/tile/badges/tile-badge-humidifier.ts +++ b/src/panels/lovelace/cards/tile/badges/tile-badge-humidifier.ts @@ -1,20 +1,32 @@ +import { html, nothing } from "lit"; +import { styleMap } from "lit/directives/style-map"; import { stateColorCss } from "../../../../../common/entity/state_color"; +import "../../../../../components/ha-attribute-icon"; +import "../../../../../components/tile/ha-tile-badge"; import { - HUMIDIFIER_ACTION_ICONS, HUMIDIFIER_ACTION_MODE, HumidifierEntity, } from "../../../../../data/humidifier"; -import { ComputeBadgeFunction } from "./tile-badge"; +import { RenderBadgeFunction } from "./tile-badge"; -export const computeHumidifierBadge: ComputeBadgeFunction = (stateObj) => { +export const renderHumidifierBadge: RenderBadgeFunction = (stateObj, hass) => { const hvacAction = (stateObj as HumidifierEntity).attributes.action; if (!hvacAction || hvacAction === "off") { - return undefined; + return nothing; } - return { - iconPath: HUMIDIFIER_ACTION_ICONS[hvacAction], - color: stateColorCss(stateObj, HUMIDIFIER_ACTION_MODE[hvacAction]), - }; + return html` + + + + + `; }; diff --git a/src/panels/lovelace/cards/tile/badges/tile-badge-person.ts b/src/panels/lovelace/cards/tile/badges/tile-badge-person.ts index 6d58f5af81ce..4c0fd8be80b7 100644 --- a/src/panels/lovelace/cards/tile/badges/tile-badge-person.ts +++ b/src/panels/lovelace/cards/tile/badges/tile-badge-person.ts @@ -1,8 +1,13 @@ import { mdiHome, mdiHomeExportOutline } from "@mdi/js"; import { HassEntity } from "home-assistant-js-websocket"; +import { html } from "lit"; +import { styleMap } from "lit/directives/style-map"; import { stateColorCss } from "../../../../../common/entity/state_color"; +import "../../../../../components/ha-icon"; +import "../../../../../components/ha-svg-icon"; +import "../../../../../components/tile/ha-tile-badge"; import { HomeAssistant } from "../../../../../types"; -import { ComputeBadgeFunction } from "./tile-badge"; +import { RenderBadgeFunction } from "./tile-badge"; function getZone(entity: HassEntity, hass: HomeAssistant) { const state = entity.state; @@ -15,17 +20,33 @@ function getZone(entity: HassEntity, hass: HomeAssistant) { return zones.find((z) => state === z.attributes.friendly_name); } -function personBadgeIcon(entity: HassEntity) { - const state = entity.state; - return state === "not_home" ? mdiHomeExportOutline : mdiHome; -} - -export const computePersonBadge: ComputeBadgeFunction = (stateObj, hass) => { +export const renderPersonBadge: RenderBadgeFunction = (stateObj, hass) => { const zone = getZone(stateObj, hass); - return { - iconPath: personBadgeIcon(stateObj), - icon: zone?.attributes.icon, - color: stateColorCss(stateObj), - }; + const zoneIcon = zone?.attributes.icon; + + if (zoneIcon) { + return html` + + + + `; + } + + const defaultIcon = + stateObj.state === "not_home" ? mdiHomeExportOutline : mdiHome; + + return html` + + + + `; }; diff --git a/src/panels/lovelace/cards/tile/badges/tile-badge.ts b/src/panels/lovelace/cards/tile/badges/tile-badge.ts index 5281f3591de3..e6bdc8fb0c38 100644 --- a/src/panels/lovelace/cards/tile/badges/tile-badge.ts +++ b/src/panels/lovelace/cards/tile/badges/tile-badge.ts @@ -1,43 +1,46 @@ import { mdiExclamationThick } from "@mdi/js"; import { HassEntity } from "home-assistant-js-websocket"; +import { TemplateResult, html, nothing } from "lit"; +import { styleMap } from "lit/directives/style-map"; import { computeDomain } from "../../../../../common/entity/compute_domain"; import { UNAVAILABLE, UNKNOWN } from "../../../../../data/entity"; import { HomeAssistant } from "../../../../../types"; -import { computeClimateBadge } from "./tile-badge-climate"; -import { computePersonBadge } from "./tile-badge-person"; -import { computeHumidifierBadge } from "./tile-badge-humidifier"; +import { renderClimateBadge } from "./tile-badge-climate"; +import { renderHumidifierBadge } from "./tile-badge-humidifier"; +import { renderPersonBadge } from "./tile-badge-person"; +import "../../../../../components/tile/ha-tile-badge"; +import "../../../../../components/ha-svg-icon"; -export type TileBadge = { - color?: string; - icon?: string; - iconPath?: string; -}; - -export type ComputeBadgeFunction = ( +export type RenderBadgeFunction = ( stateObj: HassEntity, hass: HomeAssistant -) => TileBadge | undefined; +) => TemplateResult | typeof nothing; -export const computeTileBadge: ComputeBadgeFunction = (stateObj, hass) => { +export const renderTileBadge: RenderBadgeFunction = (stateObj, hass) => { if (stateObj.state === UNKNOWN) { - return undefined; + return nothing; } if (stateObj.state === UNAVAILABLE) { - return { - color: "var(--orange-color)", - iconPath: mdiExclamationThick, - }; + return html` + + + + `; } const domain = computeDomain(stateObj.entity_id); switch (domain) { case "person": case "device_tracker": - return computePersonBadge(stateObj, hass); + return renderPersonBadge(stateObj, hass); case "climate": - return computeClimateBadge(stateObj, hass); + return renderClimateBadge(stateObj, hass); case "humidifier": - return computeHumidifierBadge(stateObj, hass); + return renderHumidifierBadge(stateObj, hass); default: - return undefined; + return nothing; } }; diff --git a/src/state-control/cover/ha-state-control-cover-toggle.ts b/src/state-control/cover/ha-state-control-cover-toggle.ts index dc26ffe24cce..b47a7b62a190 100644 --- a/src/state-control/cover/ha-state-control-cover-toggle.ts +++ b/src/state-control/cover/ha-state-control-cover-toggle.ts @@ -3,10 +3,10 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property } from "lit/decorators"; import { classMap } from "lit/directives/class-map"; import { styleMap } from "lit/directives/style-map"; -import { domainIcon } from "../../common/entity/domain_icon"; import { stateColorCss } from "../../common/entity/state_color"; import "../../components/ha-control-button"; import "../../components/ha-control-switch"; +import "../../components/ha-state-icon"; import { UNAVAILABLE, UNKNOWN } from "../../data/entity"; import { forwardHaptic } from "../../data/haptics"; import { HomeAssistant } from "../../types"; @@ -77,9 +77,11 @@ export class HaStateControlCoverToggle extends LitElement { "--color": onColor, })} > - + - +
`; @@ -102,8 +106,6 @@ export class HaStateControlCoverToggle extends LitElement { return html` + + `; } diff --git a/src/state-control/lock/ha-state-control-lock-toggle.ts b/src/state-control/lock/ha-state-control-lock-toggle.ts index 2914e17587cb..06e975ee59f1 100644 --- a/src/state-control/lock/ha-state-control-lock-toggle.ts +++ b/src/state-control/lock/ha-state-control-lock-toggle.ts @@ -9,10 +9,10 @@ import { import { customElement, property, state } from "lit/decorators"; import { classMap } from "lit/directives/class-map"; import { styleMap } from "lit/directives/style-map"; -import { domainIcon } from "../../common/entity/domain_icon"; import { stateColorCss } from "../../common/entity/state_color"; import "../../components/ha-control-button"; import "../../components/ha-control-switch"; +import "../../components/ha-state-icon"; import { UNAVAILABLE, UNKNOWN } from "../../data/entity"; import { forwardHaptic } from "../../data/haptics"; import { callProtectedLockService, LockEntity } from "../../data/lock"; @@ -81,18 +81,6 @@ export class HaStateControlLockToggle extends LitElement { const color = stateColorCss(this.stateObj); - const onIcon = domainIcon( - "lock", - this.stateObj, - locking ? "locking" : "locked" - ); - - const offIcon = domainIcon( - "lock", - this.stateObj, - unlocking ? "unlocking" : "unlocked" - ); - if (this.stateObj.state === UNKNOWN) { return html`
@@ -100,13 +88,21 @@ export class HaStateControlLockToggle extends LitElement { .label=${this.hass.localize("ui.card.lock.lock")} @click=${this._turnOn} > - + - +
`; @@ -127,16 +123,20 @@ export class HaStateControlLockToggle extends LitElement { })} .disabled=${this.stateObj.state === UNAVAILABLE} > - - + + > `; } diff --git a/src/state-control/valve/ha-state-control-valve-toggle.ts b/src/state-control/valve/ha-state-control-valve-toggle.ts index 2eb0dbd93477..b543b539d8f5 100644 --- a/src/state-control/valve/ha-state-control-valve-toggle.ts +++ b/src/state-control/valve/ha-state-control-valve-toggle.ts @@ -3,10 +3,10 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property } from "lit/decorators"; import { classMap } from "lit/directives/class-map"; import { styleMap } from "lit/directives/style-map"; -import { domainIcon } from "../../common/entity/domain_icon"; import { stateColorCss } from "../../common/entity/state_color"; import "../../components/ha-control-button"; import "../../components/ha-control-switch"; +import "../../components/ha-state-icon"; import { UNAVAILABLE, UNKNOWN } from "../../data/entity"; import { forwardHaptic } from "../../data/haptics"; import { HomeAssistant } from "../../types"; @@ -77,9 +77,11 @@ export class HaStateControlValveToggle extends LitElement { "--color": onColor, })} > - + - + `; @@ -102,8 +106,6 @@ export class HaStateControlValveToggle extends LitElement { return html` + + `; }