mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Guard for both undefined and null (#1053)
This commit is contained in:
parent
88ad376045
commit
77330d03b3
@ -51,15 +51,16 @@ class HaClimateState extends Polymer.Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
computeTarget(stateObj) {
|
computeTarget(stateObj) {
|
||||||
if ('target_temp_low' in stateObj.attributes &&
|
// We're using "!= null" on purpose so that we match both null and undefined.
|
||||||
'target_temp_high' in stateObj.attributes) {
|
if (stateObj.attributes.target_temp_low != null &&
|
||||||
|
stateObj.attributes.target_temp_high != null) {
|
||||||
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 ('temperature' in stateObj.attributes) {
|
} else if (stateObj.attributes.temperature != null) {
|
||||||
return `${stateObj.attributes.temperature} ${stateObj.attributes.unit_of_measurement}`;
|
return `${stateObj.attributes.temperature} ${stateObj.attributes.unit_of_measurement}`;
|
||||||
} else if ('target_humidity_low' in stateObj.attributes &&
|
} else if (stateObj.attributes.target_humidity_low != null &&
|
||||||
'target_humidity_high' in stateObj.attributes) {
|
stateObj.attributes.target_humidity_high != null) {
|
||||||
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 ('humidity' in stateObj.attributes) {
|
} else if (stateObj.attributes.humidity != null) {
|
||||||
return `${stateObj.attributes.humidity} ${stateObj.attributes.unit_of_measurement}`;
|
return `${stateObj.attributes.humidity} ${stateObj.attributes.unit_of_measurement}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user