mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Add open label if cover is open on tile card (#14632)
This commit is contained in:
parent
a8d242719f
commit
ba09120ff3
@ -12,6 +12,7 @@ import { computeStateDisplay } from "../../../common/entity/compute_state_displa
|
||||
import { stateActive } from "../../../common/entity/state_active";
|
||||
import { stateColorCss } from "../../../common/entity/state_color";
|
||||
import { stateIconPath } from "../../../common/entity/state_icon_path";
|
||||
import { blankBeforePercent } from "../../../common/translations/blank_before_percent";
|
||||
import "../../../components/ha-card";
|
||||
import "../../../components/tile/ha-tile-badge";
|
||||
import "../../../components/tile/ha-tile-icon";
|
||||
@ -192,30 +193,35 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
|
||||
if (domain === "light" && stateObj.state === ON) {
|
||||
const brightness = (stateObj as LightEntity).attributes.brightness;
|
||||
if (brightness) {
|
||||
return `${Math.round((brightness * 100) / 255)}%`;
|
||||
}
|
||||
}
|
||||
|
||||
if (domain === "cover" && stateObj.state === "open") {
|
||||
const position = (stateObj as CoverEntity).attributes.current_position;
|
||||
if (position) {
|
||||
return `${Math.round(position)}%`;
|
||||
return `${Math.round((brightness * 100) / 255)}${blankBeforePercent(
|
||||
this.hass!.locale
|
||||
)}%`;
|
||||
}
|
||||
}
|
||||
|
||||
if (domain === "fan" && stateObj.state === ON) {
|
||||
const speed = (stateObj as FanEntity).attributes.percentage;
|
||||
if (speed) {
|
||||
return `${Math.round(speed)}%`;
|
||||
return `${Math.round(speed)}${blankBeforePercent(this.hass!.locale)}%`;
|
||||
}
|
||||
}
|
||||
|
||||
return computeStateDisplay(
|
||||
const stateDisplay = computeStateDisplay(
|
||||
this.hass!.localize,
|
||||
stateObj,
|
||||
this.hass!.locale,
|
||||
this.hass!.entities
|
||||
);
|
||||
|
||||
if (domain === "cover" && stateObj.state === "open") {
|
||||
const position = (stateObj as CoverEntity).attributes.current_position;
|
||||
if (position && position !== 100) {
|
||||
return `${stateDisplay} - ${Math.round(position)}${blankBeforePercent(
|
||||
this.hass!.locale
|
||||
)}%`;
|
||||
}
|
||||
}
|
||||
return stateDisplay;
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
|
Loading…
x
Reference in New Issue
Block a user