Hide preset=none (#3419)

* Hide preset=none

* Add const to commit
This commit is contained in:
Paulus Schoutsen 2019-07-25 10:14:29 -07:00 committed by GitHub
parent c3118eada9
commit dae0ecce6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -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);

View File

@ -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 & {

View File

@ -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(