From e10c35f340b8e0f097a603074a6a929aca76a824 Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Tue, 29 Nov 2022 21:40:21 -0500 Subject: [PATCH] Fixed #376 - Static times can sometimes end up in the past and cause a range error --- js/component/card/air_quality_detail.js | 5 +++++ js/component/card/air_quality_summary.js | 5 +++++ js/component/card/runtime_sensor_detail.js | 5 +++++ js/component/card/runtime_thermostat_detail.js | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/js/component/card/air_quality_detail.js b/js/component/card/air_quality_detail.js index 5ff92c0..fe7ac6b 100644 --- a/js/component/card/air_quality_detail.js +++ b/js/component/card/air_quality_detail.js @@ -121,6 +121,11 @@ beestat.component.card.air_quality_detail.prototype.decorate_contents_ = functio moment().subtract(1, 'hour') ); + required_end = moment.max( + required_end, + moment(thermostat.data_begin) + ); + /** * If the needed data exists in the database and the runtime_sensor * cache is empty, then query the data. If the needed data does not exist in diff --git a/js/component/card/air_quality_summary.js b/js/component/card/air_quality_summary.js index ff38bc3..316a639 100644 --- a/js/component/card/air_quality_summary.js +++ b/js/component/card/air_quality_summary.js @@ -91,6 +91,11 @@ beestat.component.card.air_quality_summary.prototype.decorate_contents_ = functi moment().subtract(1, 'hour') ); + required_end = moment.max( + required_end, + moment(thermostat.data_begin) + ); + /** * If the needed data exists in the database and the runtime_sensor * cache is empty, then query the data. If the needed data does not exist in diff --git a/js/component/card/runtime_sensor_detail.js b/js/component/card/runtime_sensor_detail.js index 2ba7699..38f320c 100644 --- a/js/component/card/runtime_sensor_detail.js +++ b/js/component/card/runtime_sensor_detail.js @@ -123,6 +123,11 @@ beestat.component.card.runtime_sensor_detail.prototype.decorate_contents_ = func moment().subtract(1, 'hour') ); + required_end = moment.max( + required_end, + moment(thermostat.data_begin) + ); + /** * If the needed data exists in the database and the runtime_sensor cache is * empty, then query the data. If the needed data does not exist in the diff --git a/js/component/card/runtime_thermostat_detail.js b/js/component/card/runtime_thermostat_detail.js index 737c4d5..eca61f8 100644 --- a/js/component/card/runtime_thermostat_detail.js +++ b/js/component/card/runtime_thermostat_detail.js @@ -142,6 +142,11 @@ beestat.component.card.runtime_thermostat_detail.prototype.decorate_contents_ = moment().subtract(1, 'hour') ); + required_end = moment.max( + required_end, + moment(thermostat.data_begin) + ); + /** * If the needed data exists in the database and the runtime_thermostat * cache is empty, then query the data. If the needed data does not exist in