From 78fb1d99fc67ca87554ad7e09d12bff669e5fc58 Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Fri, 19 Aug 2022 14:43:00 -0400 Subject: [PATCH] Fixed sensor temperature getting ignored if the sensor does not support occupancy. --- js/component/card/three_d.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/js/component/card/three_d.js b/js/component/card/three_d.js index 432721b..6b2811d 100644 --- a/js/component/card/three_d.js +++ b/js/component/card/three_d.js @@ -424,31 +424,31 @@ beestat.component.card.three_d.prototype.get_data_ = function(force) { if (beestat.cache.data.three_d__runtime_sensor !== undefined) { // Add to data beestat.cache.data.three_d__runtime_sensor.forEach(function(runtime_sensor) { - if ( - sensor_ids_map[runtime_sensor.sensor_id] !== undefined && - runtime_sensor.temperature !== null && - runtime_sensor.occupancy !== null - ) { + if (sensor_ids_map[runtime_sensor.sensor_id] !== undefined) { const timestamp_m = moment(runtime_sensor.timestamp); const time = timestamp_m.format('HH:mm'); // Temperature - if (self.data_.series.temperature[runtime_sensor.sensor_id] === undefined) { - self.data_.series.temperature[runtime_sensor.sensor_id] = {}; + if (runtime_sensor.temperature !== null) { + if (self.data_.series.temperature[runtime_sensor.sensor_id] === undefined) { + self.data_.series.temperature[runtime_sensor.sensor_id] = {}; + } + if (self.data_.series.temperature[runtime_sensor.sensor_id][time] === undefined) { + self.data_.series.temperature[runtime_sensor.sensor_id][time] = []; + } + self.data_.series.temperature[runtime_sensor.sensor_id][time].push(runtime_sensor.temperature); } - if (self.data_.series.temperature[runtime_sensor.sensor_id][time] === undefined) { - self.data_.series.temperature[runtime_sensor.sensor_id][time] = []; - } - self.data_.series.temperature[runtime_sensor.sensor_id][time].push(runtime_sensor.temperature); // Occupancy - if (self.data_.series.occupancy[runtime_sensor.sensor_id] === undefined) { - self.data_.series.occupancy[runtime_sensor.sensor_id] = {}; + if (runtime_sensor.occupancy !== null) { + if (self.data_.series.occupancy[runtime_sensor.sensor_id] === undefined) { + self.data_.series.occupancy[runtime_sensor.sensor_id] = {}; + } + if (self.data_.series.occupancy[runtime_sensor.sensor_id][time] === undefined) { + self.data_.series.occupancy[runtime_sensor.sensor_id][time] = []; + } + self.data_.series.occupancy[runtime_sensor.sensor_id][time].push(runtime_sensor.occupancy === true ? 1 : 0); } - if (self.data_.series.occupancy[runtime_sensor.sensor_id][time] === undefined) { - self.data_.series.occupancy[runtime_sensor.sensor_id][time] = []; - } - self.data_.series.occupancy[runtime_sensor.sensor_id][time].push(runtime_sensor.occupancy === true ? 1 : 0); } });