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

View File

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

View File

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