Change attribute checks to handle if value == 0 (#1037)

if (0) is false
This commit is contained in:
c727 2018-03-28 08:57:01 +02:00 committed by Paulus Schoutsen
parent 7081fb5123
commit fb8fb09c73

View File

@ -41,9 +41,9 @@ class HaClimateState extends Polymer.Element {
} }
computeCurrentStatus(stateObj) { computeCurrentStatus(stateObj) {
if (stateObj.attributes.current_temperature) { if ('current_temperature' in stateObj.attributes) {
return `${stateObj.attributes.current_temperature} ${stateObj.attributes.unit_of_measurement}`; return `${stateObj.attributes.current_temperature} ${stateObj.attributes.unit_of_measurement}`;
} else if (stateObj.attributes.current_humidity) { } else if ('current_humidity' in stateObj.attributes) {
return `${stateObj.attributes.current_humidity} ${stateObj.attributes.unit_of_measurement}`; return `${stateObj.attributes.current_humidity} ${stateObj.attributes.unit_of_measurement}`;
} }
@ -51,15 +51,15 @@ class HaClimateState extends Polymer.Element {
} }
computeTarget(stateObj) { computeTarget(stateObj) {
if (stateObj.attributes.target_temp_low && if ('target_temp_low' in stateObj.attributes &&
stateObj.attributes.target_temp_high) { 'target_temp_high' in stateObj.attributes) {
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 ('temperature' in stateObj.attributes) {
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 && } else if ('target_humidity_low' in stateObj.attributes &&
stateObj.attributes.target_humidity_high) { 'target_humidity_high' in stateObj.attributes) {
return `${stateObj.attributes.target_humidity_low} - ${stateObj.attributes.target_humidity_high} ${stateObj.attributes.unit_of_measurement}`; return `${stateObj.attributes.target_humidity_low} - ${stateObj.attributes.target_humidity_high} ${stateObj.attributes.unit_of_measurement}`;
} else if (stateObj.attributes.humidity) { } else if ('humidity' in stateObj.attributes) {
return `${stateObj.attributes.humidity} ${stateObj.attributes.unit_of_measurement}`; return `${stateObj.attributes.humidity} ${stateObj.attributes.unit_of_measurement}`;
} }