From b1da4938f04a4ced3e398fe658f8f16120830792 Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Sat, 1 Nov 2025 08:52:30 -0400 Subject: [PATCH] Glenwood updates --- api/runtime.php | 11 ++++++----- js/component/card/glenwood_enroll.js | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/api/runtime.php b/api/runtime.php index 4e8a4d7..b7ad9f0 100644 --- a/api/runtime.php +++ b/api/runtime.php @@ -1222,6 +1222,7 @@ class runtime extends cora\api { date(max(runtime_thermostat.timestamp)) as end_date, json_unquote(user.settings->'$.glenwood_name') as glenwood_name, json_unquote(user.settings->'$.glenwood_unit') as glenwood_unit, + convert_tz(json_unquote(user.settings->'$.glenwood_enrolled_at'), '+00:00', 'America/New_York') as glenwood_enrolled_at, ecobee_thermostat.identifier as thermostat_serial_number, thermostat.name as thermostat_name, round(avg(runtime_thermostat.outdoor_temperature) / 10, 1) as average_outdoor_temperature, @@ -1256,9 +1257,7 @@ class runtime extends cora\api { user.user_id, glenwood_thermostat_ids.thermostat_id order by - glenwood_name, - glenwood_unit, - thermostat_serial_number + glenwood_unit "; $result = $this->database->query($query); @@ -1271,9 +1270,10 @@ class runtime extends cora\api { 'Name', 'Unit #', 'Serial #', + 'Enrolled At', 'Thermostat Name', - 'Average Outdoor Temp (°F)', - 'Average Indoor Temp (°F)', + 'Average Outdoor Temp (F)', + 'Average Indoor Temp (F)', 'Heat 1 Runtime (min)', 'Heat 2 Runtime (min)', 'Auxiliary Heat Runtime (min)', @@ -1291,6 +1291,7 @@ class runtime extends cora\api { $row['glenwood_name'], $row['glenwood_unit'], $row['thermostat_serial_number'], + $row['glenwood_enrolled_at'], $row['thermostat_name'], $row['average_outdoor_temperature'], $row['average_indoor_temperature'], diff --git a/js/component/card/glenwood_enroll.js b/js/component/card/glenwood_enroll.js index 9a84060..d2651ba 100644 --- a/js/component/card/glenwood_enroll.js +++ b/js/component/card/glenwood_enroll.js @@ -12,6 +12,7 @@ beestat.component.card.glenwood_enroll = function() { : $.values(beestat.cache.thermostat).map(function(thermostat) { return thermostat.thermostat_id; }); this.is_enrolled = beestat.setting('glenwood_enrolled') === true; + this.enrolled_at = beestat.setting('glenwood_enrolled_at') || null; }; beestat.extend(beestat.component.card.glenwood_enroll, beestat.component.card); @@ -29,13 +30,15 @@ beestat.component.card.glenwood_enroll.prototype.decorate_contents_ = function(p parent.appendChild(error_message_container); // Enrollment status line + var status_text = self.is_enrolled ? 'You are currently enrolled.' : 'You are not currently enrolled.'; + parent.appendChild( $.createElement('div') .style({ 'margin-bottom': beestat.style.size.gutter + 'px', 'color': self.is_enrolled ? beestat.style.color.green.base : beestat.style.color.red.base }) - .innerText(self.is_enrolled ? 'You are currently enrolled.' : 'You are not currently enrolled.') + .innerText(status_text) ); var input_container = $.createElement('div') @@ -175,13 +178,15 @@ beestat.component.card.glenwood_enroll.prototype.decorate_contents_ = function(p 'glenwood_enrolled': false, 'glenwood_name': undefined, 'glenwood_unit': undefined, - 'glenwood_thermostat_ids': undefined + 'glenwood_thermostat_ids': undefined, + 'glenwood_enrolled_at': undefined }, undefined, function() { self.is_saving = false; self.is_enrolled = false; self.name = ''; self.unit_number = ''; self.thermostat_ids = $.values(beestat.cache.thermostat).map(function(thermostat) { return thermostat.thermostat_id; }); + self.enrolled_at = null; self.rerender(); }); }); @@ -210,14 +215,18 @@ beestat.component.card.glenwood_enroll.prototype.decorate_contents_ = function(p self.is_saving = true; self.rerender(); + var enrolled_at = new Date().toISOString(); // UTC ISO 8601 timestamp + beestat.setting({ 'glenwood_enrolled': true, 'glenwood_name': self.name, 'glenwood_unit': self.unit_number, - 'glenwood_thermostat_ids': self.thermostat_ids + 'glenwood_thermostat_ids': self.thermostat_ids, + 'glenwood_enrolled_at': enrolled_at }, undefined, function() { self.is_saving = false; self.is_enrolled = true; // Update enrollment status + self.enrolled_at = enrolled_at; self.rerender(); }); });