mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
parent
c3118eada9
commit
dae0ecce6a
@ -2,6 +2,7 @@ import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import LocalizeMixin from "../mixins/localize-mixin";
|
||||
import { CLIMATE_PRESET_NONE } from "../data/climate";
|
||||
|
||||
/*
|
||||
* @appliesMixin LocalizeMixin
|
||||
@ -40,7 +41,7 @@ class HaClimateState extends LocalizeMixin(PolymerElement) {
|
||||
<template is="dom-if" if="[[_hasKnownState(stateObj.state)]]">
|
||||
<span class="state-label">
|
||||
[[_localizeState(localize, stateObj)]]
|
||||
<template is="dom-if" if="[[stateObj.attributes.preset_mode]]">
|
||||
<template is="dom-if" if="[[_renderPreset(stateObj.attributes)]]">
|
||||
- [[_localizePreset(localize, stateObj.attributes.preset_mode)]]
|
||||
</template>
|
||||
</span>
|
||||
@ -130,5 +131,11 @@ class HaClimateState extends LocalizeMixin(PolymerElement) {
|
||||
_localizePreset(localize, preset) {
|
||||
return localize(`state_attributes.climate.preset_mode.${preset}`) || preset;
|
||||
}
|
||||
|
||||
_renderPreset(attributes) {
|
||||
return (
|
||||
attributes.preset_mode && attributes.preset_mode !== CLIMATE_PRESET_NONE
|
||||
);
|
||||
}
|
||||
}
|
||||
customElements.define("ha-climate-state", HaClimateState);
|
||||
|
@ -12,6 +12,8 @@ export type HvacMode =
|
||||
| "dry"
|
||||
| "fan_only";
|
||||
|
||||
export const CLIMATE_PRESET_NONE = "none";
|
||||
|
||||
export type HvacAction = "off" | "heating" | "cooling" | "drying" | "idle";
|
||||
|
||||
export type ClimateEntity = HassEntityBase & {
|
||||
|
@ -27,6 +27,7 @@ import {
|
||||
ClimateEntity,
|
||||
HvacMode,
|
||||
compareClimateHvacModes,
|
||||
CLIMATE_PRESET_NONE,
|
||||
} from "../../../data/climate";
|
||||
|
||||
const thermostatConfig = {
|
||||
@ -155,7 +156,8 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
|
||||
}`
|
||||
)
|
||||
: this.hass!.localize(`state.climate.${stateObj.state}`)}
|
||||
${stateObj.attributes.preset_mode
|
||||
${stateObj.attributes.preset_mode &&
|
||||
stateObj.attributes.preset_mode !== CLIMATE_PRESET_NONE
|
||||
? html`
|
||||
-
|
||||
${this.hass!.localize(
|
||||
|
Loading…
x
Reference in New Issue
Block a user