Added support for humidity display in the climate state (#838)

This commit is contained in:
Fabien Piuzzi 2018-01-26 19:54:14 +01:00 committed by Paulus Schoutsen
parent d21c1bc615
commit c11a525a2d

View File

@ -21,12 +21,11 @@
<span class="state-label"> <span class="state-label">
[[stateObj.state]] [[stateObj.state]]
</span> </span>
[[computeTargetTemperature(stateObj)]] [[computeTarget(stateObj)]]
</div> </div>
<div class='current'> <div class='current'>
Currently: [[stateObj.attributes.current_temperature]] Currently: [[computeCurrentStatus(stateObj)]]
[[stateObj.attributes.unit_of_measurement]]
</div> </div>
</template> </template>
</dom-module> </dom-module>
@ -41,12 +40,27 @@ class HaClimateState extends Polymer.Element {
}; };
} }
computeTargetTemperature(stateObj) { computeCurrentStatus(stateObj) {
if (stateObj.attributes.current_temperature) {
return `${stateObj.attributes.current_temperature} ${stateObj.attributes.unit_of_measurement}`;
} else if (stateObj.attributes.current_humidity) {
return `${stateObj.attributes.current_humidity} ${stateObj.attributes.unit_of_measurement}`;
}
return '';
}
computeTarget(stateObj) {
if (stateObj.attributes.target_temp_low && if (stateObj.attributes.target_temp_low &&
stateObj.attributes.target_temp_high) { stateObj.attributes.target_temp_high) {
return `${stateObj.attributes.target_temp_low} - ${stateObj.attributes.target_temp_high} ${stateObj.attributes.unit_of_measurement}`; return `${stateObj.attributes.target_temp_low} - ${stateObj.attributes.target_temp_high} ${stateObj.attributes.unit_of_measurement}`;
} else if (stateObj.attributes.temperature) { } else if (stateObj.attributes.temperature) {
return `${stateObj.attributes.temperature} ${stateObj.attributes.unit_of_measurement}`; return `${stateObj.attributes.temperature} ${stateObj.attributes.unit_of_measurement}`;
} else if (stateObj.attributes.target_humidity_low &&
stateObj.attributes.target_humidity_high) {
return `${stateObj.attributes.target_humidity_low} - ${stateObj.attributes.target_humidity_high} ${stateObj.attributes.unit_of_measurement}`;
} else if (stateObj.attributes.humidity) {
return `${stateObj.attributes.humidity} ${stateObj.attributes.unit_of_measurement}`;
} }
return ''; return '';