Fix climate chart with unavailable states (#737)

This commit is contained in:
Andrey 2017-12-18 08:38:58 +02:00 committed by GitHub
parent 91fadccf33
commit 1aa1ac709d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -172,9 +172,8 @@
if (domain === 'thermostat' || domain === 'climate') { if (domain === 'thermostat' || domain === 'climate') {
// We differentiate between thermostats that have a target temperature // We differentiate between thermostats that have a target temperature
// range versus ones that have just a target temperature // range versus ones that have just a target temperature
hasTargetRange = states.states.reduce(function (cum, cur) { hasTargetRange = states.states.some(state => state.attributes &&
return cum || cur.attributes.target_temp_high !== cur.attributes.target_temp_low; state.attributes.target_temp_high !== state.attributes.target_temp_low);
}, false);
dataTable.addColumn('number', name + ' current temperature'); dataTable.addColumn('number', name + ' current temperature');
dataTable.addColumn('number', name + ' heating'); dataTable.addColumn('number', name + ' heating');
@ -195,6 +194,7 @@
} }
processState = function (state) { processState = function (state) {
if (!state.attributes) return;
var curTemp = saveParseFloat(state.attributes.current_temperature); var curTemp = saveParseFloat(state.attributes.current_temperature);
// Drawing the 'heating' area up to the current temp should keep it from // Drawing the 'heating' area up to the current temp should keep it from
// overlapping but avoid any weird gaps or range mismatches // overlapping but avoid any weird gaps or range mismatches