1
0
mirror of https://github.com/beestat/app.git synced 2025-05-24 02:14:03 -04:00

Fixed #370 - Removing a sensor breaks visualize

This commit is contained in:
Jon Ziebell 2022-11-07 22:29:05 -05:00
parent ab792ff696
commit 425f290a6b
5 changed files with 63 additions and 49 deletions

View File

@ -173,7 +173,10 @@ beestat.floor_plan.get_sensor_ids_map = function(floor_plan_id) {
const sensor_ids_map = {};
floor_plan.data.groups.forEach(function(group) {
group.rooms.forEach(function(room) {
if (room.sensor_id !== undefined) {
if (
room.sensor_id !== undefined &&
beestat.cache.sensor[room.sensor_id] !== undefined
) {
sensor_ids_map[room.sensor_id] = true;
}
});
@ -195,7 +198,10 @@ beestat.floor_plan.get_thermostat_ids_map = function(floor_plan_id) {
const thermostat_ids_map = {};
floor_plan.data.groups.forEach(function(group) {
group.rooms.forEach(function(room) {
if (room.sensor_id !== undefined) {
if (
room.sensor_id !== undefined &&
beestat.cache.sensor[room.sensor_id] !== undefined
) {
const sensor = beestat.cache.sensor[room.sensor_id];
thermostat_ids_map[sensor.thermostat_id] = true;
}

View File

@ -601,7 +601,10 @@ beestat.component.card.floor_plan_editor.prototype.decorate_info_pane_room_ = fu
sensor_input.render(div);
if (self.state_.active_room_entity.get_room().sensor_id !== undefined) {
if (
self.state_.active_room_entity.get_room().sensor_id !== undefined &&
beestat.cache.sensor[self.state_.active_room_entity.get_room().sensor_id] !== undefined
) {
sensor_input.set_value(self.state_.active_room_entity.get_room().sensor_id);
} else {
sensor_input.set_value('');

View File

@ -430,7 +430,8 @@ beestat.component.card.three_d.prototype.decorate_controls_ = function(parent) {
let thermostat_ids;
if (
active_room !== null &&
active_room.sensor_id !== undefined
active_room.sensor_id !== undefined &&
beestat.cache.sensor[active_room.sensor_id] !== undefined
) {
thermostat_ids = [beestat.cache.sensor[active_room.sensor_id].thermostat_id];
} else {

View File

@ -41,7 +41,6 @@ beestat.component.input.select.prototype.decorate_ = function(parent) {
this.input_.style.color = '#fff';
this.input_.style.outline = 'none';
this.input_.style.transition = 'background 200ms ease';
this.input_.style.marginBottom = beestat.style.size.gutter + 'px';
this.input_.style.borderBottom = '2px solid ' + beestat.style.color.lightblue.base;
// Clear any existing option values from the input.

View File

@ -411,50 +411,52 @@ beestat.component.scene.prototype.update_ = function() {
const sensor = beestat.cache.sensor[room.sensor_id];
let icon;
let icon_opacity;
if (
self.data_.series.compressor_cool_1[sensor.thermostat_id][time] !== undefined &&
self.data_.series.compressor_cool_1[sensor.thermostat_id][time] > 0
) {
icon = 'snowflake';
icon_opacity = self.data_.series.compressor_cool_1[sensor.thermostat_id][time];
} else if (
self.data_.series.compressor_cool_2[sensor.thermostat_id][time] !== undefined &&
self.data_.series.compressor_cool_2[sensor.thermostat_id][time] > 0
) {
icon = 'snowflake';
icon_opacity = self.data_.series.compressor_cool_2[sensor.thermostat_id][time];
} else if (
self.data_.series.compressor_heat_1[sensor.thermostat_id][time] !== undefined &&
self.data_.series.compressor_heat_1[sensor.thermostat_id][time] > 0
) {
icon = 'fire';
icon_opacity = self.data_.series.compressor_heat_1[sensor.thermostat_id][time];
} else if (
self.data_.series.compressor_heat_2[sensor.thermostat_id][time] !== undefined &&
self.data_.series.compressor_heat_2[sensor.thermostat_id][time] > 0
) {
icon = 'fire';
icon_opacity = self.data_.series.compressor_heat_2[sensor.thermostat_id][time];
} else if (
self.data_.series.auxiliary_heat_1[sensor.thermostat_id][time] !== undefined &&
self.data_.series.auxiliary_heat_1[sensor.thermostat_id][time] > 0
) {
icon = 'fire';
icon_opacity = self.data_.series.auxiliary_heat_1[sensor.thermostat_id][time];
} else if (
self.data_.series.auxiliary_heat_2[sensor.thermostat_id][time] !== undefined &&
self.data_.series.auxiliary_heat_2[sensor.thermostat_id][time] > 0
) {
icon = 'fire';
icon_opacity = self.data_.series.auxiliary_heat_2[sensor.thermostat_id][time];
} else if (
self.data_.series.fan[sensor.thermostat_id][time] !== undefined &&
self.data_.series.fan[sensor.thermostat_id][time] > 0
) {
icon = 'fan';
icon_opacity = self.data_.series.fan[sensor.thermostat_id][time];
if (sensor !== undefined) {
if (
self.data_.series.compressor_cool_1[sensor.thermostat_id][time] !== undefined &&
self.data_.series.compressor_cool_1[sensor.thermostat_id][time] > 0
) {
icon = 'snowflake';
icon_opacity = self.data_.series.compressor_cool_1[sensor.thermostat_id][time];
} else if (
self.data_.series.compressor_cool_2[sensor.thermostat_id][time] !== undefined &&
self.data_.series.compressor_cool_2[sensor.thermostat_id][time] > 0
) {
icon = 'snowflake';
icon_opacity = self.data_.series.compressor_cool_2[sensor.thermostat_id][time];
} else if (
self.data_.series.compressor_heat_1[sensor.thermostat_id][time] !== undefined &&
self.data_.series.compressor_heat_1[sensor.thermostat_id][time] > 0
) {
icon = 'fire';
icon_opacity = self.data_.series.compressor_heat_1[sensor.thermostat_id][time];
} else if (
self.data_.series.compressor_heat_2[sensor.thermostat_id][time] !== undefined &&
self.data_.series.compressor_heat_2[sensor.thermostat_id][time] > 0
) {
icon = 'fire';
icon_opacity = self.data_.series.compressor_heat_2[sensor.thermostat_id][time];
} else if (
self.data_.series.auxiliary_heat_1[sensor.thermostat_id][time] !== undefined &&
self.data_.series.auxiliary_heat_1[sensor.thermostat_id][time] > 0
) {
icon = 'fire';
icon_opacity = self.data_.series.auxiliary_heat_1[sensor.thermostat_id][time];
} else if (
self.data_.series.auxiliary_heat_2[sensor.thermostat_id][time] !== undefined &&
self.data_.series.auxiliary_heat_2[sensor.thermostat_id][time] > 0
) {
icon = 'fire';
icon_opacity = self.data_.series.auxiliary_heat_2[sensor.thermostat_id][time];
} else if (
self.data_.series.fan[sensor.thermostat_id][time] !== undefined &&
self.data_.series.fan[sensor.thermostat_id][time] > 0
) {
icon = 'fan';
icon_opacity = self.data_.series.fan[sensor.thermostat_id][time];
}
icon_opacity = Math.round(icon_opacity * 10) / 10;
}
icon_opacity = Math.round(icon_opacity * 10) / 10;
// Labels
if (
@ -559,7 +561,10 @@ beestat.component.scene.prototype.add_room_ = function(layer, group, room) {
const material = new THREE.MeshPhongMaterial({
'color': color
});
if (room.sensor_id === undefined) {
if (
room.sensor_id === undefined ||
beestat.cache.sensor[room.sensor_id] === undefined
) {
const loader = new THREE.TextureLoader();
loader.load(
'img/visualize/stripe.png',