mirror of
https://github.com/beestat/app.git
synced 2025-06-23 15:30:43 -04:00
Air Quality for all!
This commit is contained in:
parent
56995a04eb
commit
eb3532f7c4
@ -425,6 +425,7 @@ input[type=checkbox] {
|
|||||||
.icon.numeric_4_box:before { content: "\F03AD"; }
|
.icon.numeric_4_box:before { content: "\F03AD"; }
|
||||||
.icon.numeric_3_box:before { content: "\F03AA"; }
|
.icon.numeric_3_box:before { content: "\F03AA"; }
|
||||||
.icon.numeric_7_box:before { content: "\F03B6"; }
|
.icon.numeric_7_box:before { content: "\F03B6"; }
|
||||||
|
.icon.open_in_new:before { content: "\F03CC"; }
|
||||||
.icon.patreon:before { content: "\F0882"; }
|
.icon.patreon:before { content: "\F0882"; }
|
||||||
.icon.pound:before { content: "\F0423"; }
|
.icon.pound:before { content: "\F0423"; }
|
||||||
.icon.refresh:before { content: "\F0450"; }
|
.icon.refresh:before { content: "\F0450"; }
|
||||||
|
@ -51,7 +51,7 @@ beestat.setting = function(argument_1, opt_value, opt_callback) {
|
|||||||
.subtract(28, 'day')
|
.subtract(28, 'day')
|
||||||
.format('MM/DD/YYYY'),
|
.format('MM/DD/YYYY'),
|
||||||
'voc_summary_range_static_end': moment().format('MM/DD/YYYY'),
|
'voc_summary_range_static_end': moment().format('MM/DD/YYYY'),
|
||||||
'voc_summary_range_dynamic': 30,
|
'voc_summary_range_dynamic': 28,
|
||||||
|
|
||||||
'runtime_thermostat_summary_time_count': 0,
|
'runtime_thermostat_summary_time_count': 0,
|
||||||
'runtime_thermostat_summary_time_period': 'all',
|
'runtime_thermostat_summary_time_period': 'all',
|
||||||
|
@ -175,3 +175,17 @@ beestat.thermostat.get_current_climate = function(thermostat_id) {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether or not the thermostat supports air quality.
|
||||||
|
*
|
||||||
|
* @param {number} thermostat_id
|
||||||
|
* @param {string} climate_ref The ecobee climateRef
|
||||||
|
*
|
||||||
|
* @return {boolean} Whether or not the thermostat supports air quality.
|
||||||
|
*/
|
||||||
|
beestat.thermostat.supports_air_quality = function(thermostat_id) {
|
||||||
|
const thermostat = beestat.cache.thermostat[thermostat_id];
|
||||||
|
const ecobee_thermostat = beestat.cache.ecobee_thermostat[thermostat.ecobee_thermostat_id];
|
||||||
|
return ecobee_thermostat.model_number === 'aresSmart';
|
||||||
|
};
|
||||||
|
@ -368,6 +368,21 @@ beestat.component.card.air_quality_detail.prototype.get_data_ = function(force)
|
|||||||
|
|
||||||
this.data_ = sensor_data;
|
this.data_ = sensor_data;
|
||||||
|
|
||||||
|
if (beestat.thermostat.supports_air_quality(this.thermostat_id_) === false) {
|
||||||
|
// Override with 0s for unsupported thermostats so the charts look ok.
|
||||||
|
for (let i = 0; i < sensor_data.series['voc_concentration_' + this.thermostat_id_].length; i++) {
|
||||||
|
sensor_data.series['air_quality_' + this.thermostat_id_][i] = 0;
|
||||||
|
sensor_data.series['voc_concentration_' + this.thermostat_id_][i] = 0;
|
||||||
|
sensor_data.series['co2_concentration_' + this.thermostat_id_][i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let timestamp in sensor_data.metadata.series['air_quality_' + this.thermostat_id_].data) {
|
||||||
|
sensor_data.metadata.series['air_quality_' + this.thermostat_id_].data[timestamp] = 0;
|
||||||
|
sensor_data.metadata.series['voc_concentration_' + this.thermostat_id_].data[timestamp] = 0;
|
||||||
|
sensor_data.metadata.series['co2_concentration_' + this.thermostat_id_].data[timestamp] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Object.assign(this.data_.series, thermostat_data.series);
|
Object.assign(this.data_.series, thermostat_data.series);
|
||||||
Object.assign(this.data_.metadata.series, thermostat_data.metadata.series);
|
Object.assign(this.data_.metadata.series, thermostat_data.metadata.series);
|
||||||
|
|
||||||
|
36
js/component/card/air_quality_not_supported.js
Normal file
36
js/component/card/air_quality_not_supported.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/**
|
||||||
|
* Air Quality Not Supported
|
||||||
|
*/
|
||||||
|
beestat.component.card.air_quality_not_supported = function() {
|
||||||
|
beestat.component.card.apply(this, arguments);
|
||||||
|
};
|
||||||
|
beestat.extend(beestat.component.card.air_quality_not_supported, beestat.component.card);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decorate
|
||||||
|
*
|
||||||
|
* @param {rocket.Elements} parent
|
||||||
|
*/
|
||||||
|
beestat.component.card.air_quality_not_supported.prototype.decorate_contents_ = function(parent) {
|
||||||
|
parent.style('background', beestat.style.color.blue.light);
|
||||||
|
parent.appendChild($.createElement('p').innerText('Access to Air Quality information requires a compatible thermostat. Support beestat by buying through this affiliate link.'));
|
||||||
|
|
||||||
|
new beestat.component.button()
|
||||||
|
.set_icon('open_in_new')
|
||||||
|
.set_text('Buy an ecobee Smart Thermostat Premium on Amazon')
|
||||||
|
.set_background_color(beestat.style.color.green.dark)
|
||||||
|
.set_background_hover_color(beestat.style.color.green.light)
|
||||||
|
.addEventListener('click', function() {
|
||||||
|
window.open('https://amzn.to/3A7vv3S');
|
||||||
|
})
|
||||||
|
.render(parent);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the title of the card.
|
||||||
|
*
|
||||||
|
* @return {string} The title.
|
||||||
|
*/
|
||||||
|
beestat.component.card.air_quality_not_supported.prototype.get_title_ = function() {
|
||||||
|
return 'Unsupported Thermostat';
|
||||||
|
};
|
@ -253,9 +253,14 @@ beestat.component.card.voc_summary.prototype.decorate_chart_ = function(parent)
|
|||||||
var background = beestat.style.color.bluegray.light;
|
var background = beestat.style.color.bluegray.light;
|
||||||
|
|
||||||
if (cell_value !== undefined) {
|
if (cell_value !== undefined) {
|
||||||
var average = grid_data[day + '_' + hour].reduce(function(a, b) {
|
var average;
|
||||||
|
if (grid_data[day + '_' + hour].length > 0) {
|
||||||
|
average = grid_data[day + '_' + hour].reduce(function(a, b) {
|
||||||
return a + b;
|
return a + b;
|
||||||
}) / grid_data[day + '_' + hour].length;
|
}) / grid_data[day + '_' + hour].length;
|
||||||
|
} else {
|
||||||
|
average = 0;
|
||||||
|
}
|
||||||
|
|
||||||
td.setAttribute('title', Math.round(average) + ' ppb');
|
td.setAttribute('title', Math.round(average) + ' ppb');
|
||||||
|
|
||||||
@ -366,7 +371,7 @@ beestat.component.card.voc_summary.prototype.has_data_ = function() {
|
|||||||
* @return {string} Title
|
* @return {string} Title
|
||||||
*/
|
*/
|
||||||
beestat.component.card.voc_summary.prototype.get_title_ = function() {
|
beestat.component.card.voc_summary.prototype.get_title_ = function() {
|
||||||
return 'TVOC Summary';
|
return 'TVOC Concentration Summary';
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,11 +24,6 @@ beestat.component.header.prototype.rerender_on_breakpoint_ = true;
|
|||||||
beestat.component.header.prototype.decorate_ = function(parent) {
|
beestat.component.header.prototype.decorate_ = function(parent) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
const thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')];
|
|
||||||
const ecobee_thermostat = beestat.cache.ecobee_thermostat[
|
|
||||||
thermostat.ecobee_thermostat_id
|
|
||||||
];
|
|
||||||
|
|
||||||
var pages;
|
var pages;
|
||||||
|
|
||||||
pages = [
|
pages = [
|
||||||
@ -49,16 +44,11 @@ beestat.component.header.prototype.decorate_ = function(parent) {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
if (
|
|
||||||
beestat.user.has_early_access() === true &&
|
|
||||||
ecobee_thermostat.model_number === 'aresSmart'
|
|
||||||
) {
|
|
||||||
pages.push({
|
pages.push({
|
||||||
'layer': 'air_quality',
|
'layer': 'air_quality',
|
||||||
'text': 'Air Quality',
|
'text': 'Air Quality',
|
||||||
'icon': 'weather_windy'
|
'icon': 'weather_windy'
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
var gutter = beestat.style.size.gutter;
|
var gutter = beestat.style.size.gutter;
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ if($setting->get('environment') === 'dev' || $setting->get('environment') === 'd
|
|||||||
echo '<script src="/js/component/card/settings.js"></script>' . PHP_EOL;
|
echo '<script src="/js/component/card/settings.js"></script>' . PHP_EOL;
|
||||||
echo '<script src="/js/component/card/air_quality_detail.js"></script>' . PHP_EOL;
|
echo '<script src="/js/component/card/air_quality_detail.js"></script>' . PHP_EOL;
|
||||||
echo '<script src="/js/component/card/voc_summary.js"></script>' . PHP_EOL;
|
echo '<script src="/js/component/card/voc_summary.js"></script>' . PHP_EOL;
|
||||||
|
echo '<script src="/js/component/card/air_quality_not_supported.js"></script>' . PHP_EOL;
|
||||||
echo '<script src="/js/component/chart.js"></script>' . PHP_EOL;
|
echo '<script src="/js/component/chart.js"></script>' . PHP_EOL;
|
||||||
echo '<script src="/js/component/chart/runtime_thermostat_summary.js"></script>' . PHP_EOL;
|
echo '<script src="/js/component/chart/runtime_thermostat_summary.js"></script>' . PHP_EOL;
|
||||||
echo '<script src="/js/component/chart/temperature_profiles.js"></script>' . PHP_EOL;
|
echo '<script src="/js/component/chart/temperature_profiles.js"></script>' . PHP_EOL;
|
||||||
|
@ -7,8 +7,6 @@ beestat.layer.air_quality = function() {
|
|||||||
beestat.extend(beestat.layer.air_quality, beestat.layer);
|
beestat.extend(beestat.layer.air_quality, beestat.layer);
|
||||||
|
|
||||||
beestat.layer.air_quality.prototype.decorate_ = function(parent) {
|
beestat.layer.air_quality.prototype.decorate_ = function(parent) {
|
||||||
const thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the overflow on the body so the scrollbar is always present so
|
* Set the overflow on the body so the scrollbar is always present so
|
||||||
* highcharts graphs render properly.
|
* highcharts graphs render properly.
|
||||||
@ -33,19 +31,21 @@ beestat.layer.air_quality.prototype.decorate_ = function(parent) {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (beestat.thermostat.supports_air_quality(beestat.setting('thermostat_id')) === false) {
|
||||||
cards.push([
|
cards.push([
|
||||||
{
|
{
|
||||||
'card': new beestat.component.card.early_access(
|
'card': new beestat.component.card.air_quality_not_supported(
|
||||||
thermostat.thermostat_id
|
beestat.setting('thermostat_id')
|
||||||
),
|
),
|
||||||
'size': 12
|
'size': 12
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
cards.push([
|
cards.push([
|
||||||
{
|
{
|
||||||
'card': new beestat.component.card.air_quality_detail(
|
'card': new beestat.component.card.air_quality_detail(
|
||||||
thermostat.thermostat_id
|
beestat.setting('thermostat_id')
|
||||||
),
|
),
|
||||||
'size': 12
|
'size': 12
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ beestat.layer.air_quality.prototype.decorate_ = function(parent) {
|
|||||||
cards.push([
|
cards.push([
|
||||||
{
|
{
|
||||||
'card': new beestat.component.card.voc_summary(
|
'card': new beestat.component.card.voc_summary(
|
||||||
thermostat.thermostat_id
|
beestat.setting('thermostat_id')
|
||||||
),
|
),
|
||||||
'size': 12
|
'size': 12
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user