mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-20 15:56:35 +00:00
more-info-climate.html use supported_features (#849)
* Added supported features for controls * Improved supported features * Removed lines resulted from rebase * Fixed lint and review * Added more supported_features and fixed fan mode bug
This commit is contained in:
parent
10c07673c1
commit
1783696ecb
@ -39,6 +39,8 @@
|
|||||||
.has-away_mode .container-away_mode,
|
.has-away_mode .container-away_mode,
|
||||||
.has-aux_heat .container-aux_heat,
|
.has-aux_heat .container-aux_heat,
|
||||||
.has-target_temperature .container-temperature,
|
.has-target_temperature .container-temperature,
|
||||||
|
.has-target_temperature_low .container-temperature,
|
||||||
|
.has-target_temperature_high .container-temperature,
|
||||||
.has-target_humidity .container-humidity,
|
.has-target_humidity .container-humidity,
|
||||||
.has-operation_mode .container-operation_list,
|
.has-operation_mode .container-operation_list,
|
||||||
.has-fan_mode .container-fan_list,
|
.has-fan_mode .container-fan_list,
|
||||||
@ -104,6 +106,8 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class$='[[computeClassNames(stateObj)]]'>
|
<div class$='[[computeClassNames(stateObj)]]'>
|
||||||
|
|
||||||
|
<template is='dom-if' if='[[supportsOn(stateObj)]]'>
|
||||||
<div class='container-on'>
|
<div class='container-on'>
|
||||||
<div class='center horizontal layout single-row'>
|
<div class='center horizontal layout single-row'>
|
||||||
<div class='flex'>On / Off</div>
|
<div class='flex'>On / Off</div>
|
||||||
@ -113,12 +117,13 @@
|
|||||||
</paper-toggle-button>
|
</paper-toggle-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<div class='container-temperature'>
|
<div class='container-temperature'>
|
||||||
<div class$='[[stateObj.attributes.operation_mode]]'>
|
<div class$='[[stateObj.attributes.operation_mode]]'>
|
||||||
<div hidden$='[[computeTargetTempHidden(stateObj)]]'>Target
|
<div hidden$='[[!supportsTemperatureControls(stateObj)]]'>Target
|
||||||
Temperature</div>
|
Temperature</div>
|
||||||
<template is='dom-if' if='[[computeIncludeTempControl(stateObj)]]'>
|
<template is='dom-if' if='[[supportsTemperature(stateObj)]]'>
|
||||||
<ha-climate-control
|
<ha-climate-control
|
||||||
value='[[stateObj.attributes.temperature]]'
|
value='[[stateObj.attributes.temperature]]'
|
||||||
units='[[stateObj.attributes.unit_of_measurement]]'
|
units='[[stateObj.attributes.unit_of_measurement]]'
|
||||||
@ -129,7 +134,7 @@
|
|||||||
>
|
>
|
||||||
</ha-climate-control>
|
</ha-climate-control>
|
||||||
</template>
|
</template>
|
||||||
<template is='dom-if' if='[[computeIncludeTempRangeControl(stateObj)]]'>
|
<template is='dom-if' if='[[supportsTemperatureRange(stateObj)]]'>
|
||||||
<ha-climate-control
|
<ha-climate-control
|
||||||
value='[[stateObj.attributes.target_temp_low]]'
|
value='[[stateObj.attributes.target_temp_low]]'
|
||||||
units='[[stateObj.attributes.unit_of_measurement]]'
|
units='[[stateObj.attributes.unit_of_measurement]]'
|
||||||
@ -154,6 +159,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<template is='dom-if' if='[[supportsHumidity(stateObj)]]'>
|
||||||
<div class='container-humidity'>
|
<div class='container-humidity'>
|
||||||
<div>Target Humidity</div>
|
<div>Target Humidity</div>
|
||||||
<div class="single-row">
|
<div class="single-row">
|
||||||
@ -169,7 +175,9 @@
|
|||||||
</paper-slider>
|
</paper-slider>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template is='dom-if' if='[[supportsOperationMode(stateObj)]]'>
|
||||||
<div class='container-operation_list'>
|
<div class='container-operation_list'>
|
||||||
<div class='controls'>
|
<div class='controls'>
|
||||||
<paper-dropdown-menu class='capitalize' label-float dynamic-align label='Operation'>
|
<paper-dropdown-menu class='capitalize' label-float dynamic-align label='Operation'>
|
||||||
@ -183,7 +191,9 @@
|
|||||||
</paper-dropdown-menu>
|
</paper-dropdown-menu>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template is='dom-if' if='[[supportsFanMode(stateObj)]]'>
|
||||||
<div class='container-fan_list'>
|
<div class='container-fan_list'>
|
||||||
<paper-dropdown-menu label-float dynamic-align label='Fan Mode'>
|
<paper-dropdown-menu label-float dynamic-align label='Fan Mode'>
|
||||||
<paper-listbox slot="dropdown-content" selected="{{fanIndex}}">
|
<paper-listbox slot="dropdown-content" selected="{{fanIndex}}">
|
||||||
@ -195,7 +205,9 @@
|
|||||||
</paper-listbox>
|
</paper-listbox>
|
||||||
</paper-dropdown-menu>
|
</paper-dropdown-menu>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template is='dom-if' if='[[supportsSwingMode(stateObj)]]'>
|
||||||
<div class='container-swing_list'>
|
<div class='container-swing_list'>
|
||||||
<paper-dropdown-menu label-float dynamic-align label='Swing Mode'>
|
<paper-dropdown-menu label-float dynamic-align label='Swing Mode'>
|
||||||
<paper-listbox slot="dropdown-content" selected="{{swingIndex}}">
|
<paper-listbox slot="dropdown-content" selected="{{swingIndex}}">
|
||||||
@ -207,7 +219,9 @@
|
|||||||
</paper-listbox>
|
</paper-listbox>
|
||||||
</paper-dropdown-menu>
|
</paper-dropdown-menu>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template is='dom-if' if='[[supportsAwayMode(stateObj)]]'>
|
||||||
<div class='container-away_mode'>
|
<div class='container-away_mode'>
|
||||||
<div class='center horizontal layout single-row'>
|
<div class='center horizontal layout single-row'>
|
||||||
<div class='flex'>Away Mode</div>
|
<div class='flex'>Away Mode</div>
|
||||||
@ -217,7 +231,9 @@
|
|||||||
</paper-toggle-button>
|
</paper-toggle-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template is='dom-if' if='[[supportsAuxHeat(stateObj)]]'>
|
||||||
<div class='container-aux_heat'>
|
<div class='container-aux_heat'>
|
||||||
<div class='center horizontal layout single-row'>
|
<div class='center horizontal layout single-row'>
|
||||||
<div class='flex'>Aux Heat</div>
|
<div class='flex'>Aux Heat</div>
|
||||||
@ -227,6 +243,7 @@
|
|||||||
</paper-toggle-button>
|
</paper-toggle-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</dom-module>
|
</dom-module>
|
||||||
@ -263,7 +280,6 @@ class MoreInfoClimate extends window.hassMixins.EventsMixin(Polymer.Element) {
|
|||||||
value: -1,
|
value: -1,
|
||||||
observer: 'handleSwingmodeChanged',
|
observer: 'handleSwingmodeChanged',
|
||||||
},
|
},
|
||||||
|
|
||||||
awayToggleChecked: Boolean,
|
awayToggleChecked: Boolean,
|
||||||
auxToggleChecked: Boolean,
|
auxToggleChecked: Boolean,
|
||||||
onToggleChecked: Boolean,
|
onToggleChecked: Boolean,
|
||||||
@ -309,7 +325,7 @@ class MoreInfoClimate extends window.hassMixins.EventsMixin(Polymer.Element) {
|
|||||||
this.fanIndex = -1;
|
this.fanIndex = -1;
|
||||||
if (this.stateObj.attributes.fan_list) {
|
if (this.stateObj.attributes.fan_list) {
|
||||||
this.fanIndex =
|
this.fanIndex =
|
||||||
this.stateObj.attributes.fan_list.indexOf(this.stateObj.attributes.fan_list);
|
this.stateObj.attributes.fan_list.indexOf(this.stateObj.attributes.fan_mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,19 +338,45 @@ class MoreInfoClimate extends window.hassMixins.EventsMixin(Polymer.Element) {
|
|||||||
return 0.5;
|
return 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
computeTargetTempHidden(stateObj) {
|
supportsTemperatureControls(stateObj) {
|
||||||
return !stateObj.attributes.temperature &&
|
return this.supportsTemperature(stateObj) ||
|
||||||
!stateObj.attributes.target_temp_low &&
|
this.supportsTemperatureRange(stateObj);
|
||||||
!stateObj.attributes.target_temp_high;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
computeIncludeTempRangeControl(stateObj) {
|
supportsTemperature(stateObj) {
|
||||||
return stateObj.attributes.target_temp_low ||
|
return (stateObj.attributes.supported_features & 1) !== 0;
|
||||||
stateObj.attributes.target_temp_high;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
computeIncludeTempControl(stateObj) {
|
supportsTemperatureRange(stateObj) {
|
||||||
return stateObj.attributes.temperature;
|
return (stateObj.attributes.supported_features & 6) !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
supportsHumidity(stateObj) {
|
||||||
|
return (stateObj.attributes.supported_features & 8) !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
supportsFanMode(stateObj) {
|
||||||
|
return (stateObj.attributes.supported_features & 64) !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
supportsOperationMode(stateObj) {
|
||||||
|
return (stateObj.attributes.supported_features & 128) !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
supportsSwingMode(stateObj) {
|
||||||
|
return (stateObj.attributes.supported_features & 512) !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
supportsAwayMode(stateObj) {
|
||||||
|
return (stateObj.attributes.supported_features & 1024) !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
supportsAuxHeat(stateObj) {
|
||||||
|
return (stateObj.attributes.supported_features & 2048) !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
supportsOn(stateObj) {
|
||||||
|
return (stateObj.attributes.supported_features & 4096) !== 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
computeClassNames(stateObj) {
|
computeClassNames(stateObj) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user