From c015f634eb35eea37db39b28368ff2133c881dd6 Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Fri, 14 Jun 2024 22:23:27 -0400 Subject: [PATCH] Added system off time to thermostat detail --- js/beestat/runtime_thermostat.js | 50 +++++++++++++++++++ js/beestat/style.js | 5 ++ .../runtime_thermostat_detail_temperature.js | 20 +++++++- 3 files changed, 74 insertions(+), 1 deletion(-) diff --git a/js/beestat/runtime_thermostat.js b/js/beestat/runtime_thermostat.js index b224b9a..734c3d8 100644 --- a/js/beestat/runtime_thermostat.js +++ b/js/beestat/runtime_thermostat.js @@ -82,6 +82,7 @@ beestat.runtime_thermostat.get_data = function(thermostat_id, range, key) { 'dehumidifier', 'ventilator', 'economizer', + 'off_heat_cool', 'dummy' ].forEach(function(series_code) { data.series[series_code] = []; @@ -383,6 +384,54 @@ beestat.runtime_thermostat.get_data = function(thermostat_id, range, key) { durations.economizer = {'seconds': 0}; } + // System off duration + if ( + durations.off_heat_cool.seconds === 0 && + ( + runtime_thermostat.compressor_1 < 300 && + runtime_thermostat.compressor_2 < 300 && + runtime_thermostat.auxiliary_heat_1 < 300 && + runtime_thermostat.auxiliary_heat_2 < 300 && + runtime_thermostat.fan < 300 + ) + ) { + // If currently running and it stops. + durations.off_heat_cool = { + 'seconds': 300 - Math.max( + runtime_thermostat.compressor_1, + runtime_thermostat.compressor_2, + runtime_thermostat.auxiliary_heat_1, + runtime_thermostat.auxiliary_heat_2 + ) + }; + } else if ( + durations.off_heat_cool.seconds > 0 && + ( + runtime_thermostat.compressor_1 > 0 || + runtime_thermostat.compressor_2 > 0 || + runtime_thermostat.auxiliary_heat_1 > 0 || + runtime_thermostat.auxiliary_heat_2 > 0 + ) + ) { + // If not currently running and it starts + durations.off_heat_cool.seconds += + Math.max( + runtime_thermostat.compressor_1, + runtime_thermostat.compressor_2, + runtime_thermostat.auxiliary_heat_1, + runtime_thermostat.auxiliary_heat_2 + ); + + durations.off_heat_cool = {'seconds': 0}; + } else if ( + durations.off_heat_cool.seconds > 0 + ) { + // If not currently running + durations.off_heat_cool.seconds += 300; + } + + data.metadata.series.off_heat_cool.durations[current_m.valueOf()] = durations.off_heat_cool; + // Equipment [ 'fan', @@ -505,6 +554,7 @@ beestat.runtime_thermostat.get_data = function(thermostat_id, range, key) { data.series.dehumidifier.push(null); data.series.ventilator.push(null); data.series.economizer.push(null); + data.series.off_heat_cool.push(null); } current_m.add(5, 'minute'); diff --git a/js/beestat/style.js b/js/beestat/style.js index 2db4204..79e5ee6 100644 --- a/js/beestat/style.js +++ b/js/beestat/style.js @@ -154,6 +154,11 @@ beestat.series.fan = { 'color': beestat.style.color.gray.base }; +beestat.series.off_heat_cool = { + 'name': 'System Off', + 'color': beestat.style.color.gray.base +}; + beestat.series.humidifier = { 'name': 'Humidifier', 'color': beestat.style.color.gray.light diff --git a/js/component/chart/runtime_thermostat_detail_temperature.js b/js/component/chart/runtime_thermostat_detail_temperature.js index 07667bf..d71434f 100644 --- a/js/component/chart/runtime_thermostat_detail_temperature.js +++ b/js/component/chart/runtime_thermostat_detail_temperature.js @@ -179,7 +179,8 @@ beestat.component.chart.runtime_thermostat_detail_temperature.prototype.get_opti var groups = { 'mode': [], 'data': [], - 'equipment': [] + 'equipment': [], + 'off': [] }; var visible_series = []; @@ -378,6 +379,19 @@ beestat.component.chart.runtime_thermostat_detail_temperature.prototype.get_opti } }); + if ( + self.data_.metadata.series.off_heat_cool.durations[x.valueOf()] !== undefined && + self.data_.metadata.series.off_heat_cool.durations[x.valueOf()].seconds > 0 + ) { + groups.off.push({ + 'label': beestat.series.off_heat_cool.name, + 'value': beestat.time( + self.data_.metadata.series.off_heat_cool.durations[x.valueOf()] + ), + 'color': beestat.series.off_heat_cool.color + }); + } + if ( groups.mode.length === 0 && groups.equipment.length === 0 && @@ -394,6 +408,10 @@ beestat.component.chart.runtime_thermostat_detail_temperature.prototype.get_opti sections.push(groups.data); sections.push(groups.equipment); + if(beestat.user.has_early_access() === true) { + sections.push(groups.off); + } + var title = this.x.format('ddd, MMM D @ h:mma'); return self.tooltip_formatter_helper_(