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