1
0
mirror of https://github.com/beestat/app.git synced 2026-04-28 03:40:51 -04:00

Glenwood updates

This commit is contained in:
Jon Ziebell 2025-11-01 08:52:30 -04:00
parent f0d9cd1c8b
commit b1da4938f0
2 changed files with 18 additions and 8 deletions

View File

@ -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'],

View File

@ -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();
});
});