mirror of
https://github.com/beestat/app.git
synced 2025-06-23 15:30:43 -04:00
Moved thermostat system type and stage count logic into dedicated functions
This commit is contained in:
parent
cda8857019
commit
f6f544ba35
@ -57,3 +57,43 @@ beestat.thermostat.data_synced = function(thermostat_id, required_sync_begin, re
|
|||||||
current_sync_end.isSameOrAfter(required_sync_end) === true
|
current_sync_end.isSameOrAfter(required_sync_end) === true
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to get any system type.
|
||||||
|
*
|
||||||
|
* @param {number} thermostat_id
|
||||||
|
* @param {string} mode heat|auxiliary_heat|cool
|
||||||
|
*
|
||||||
|
* @return {string} The system type.
|
||||||
|
*/
|
||||||
|
beestat.thermostat.get_system_type = function(thermostat_id, mode) {
|
||||||
|
const thermostat = beestat.cache.thermostat[thermostat_id];
|
||||||
|
|
||||||
|
if (thermostat.system_type2.reported[mode].equipment !== null) {
|
||||||
|
return thermostat.system_type2.reported[mode].equipment;
|
||||||
|
} else if (thermostat.system_type2.detected[mode].equipment !== null) {
|
||||||
|
return thermostat.system_type2.detected[mode].equipment;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'unknown';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to get any stages.
|
||||||
|
*
|
||||||
|
* @param {number} thermostat_id
|
||||||
|
* @param {string} mode heat|auxiliary_heat|cool
|
||||||
|
*
|
||||||
|
* @return {string} The system type.
|
||||||
|
*/
|
||||||
|
beestat.thermostat.get_stages = function(thermostat_id, mode) {
|
||||||
|
const thermostat = beestat.cache.thermostat[thermostat_id];
|
||||||
|
|
||||||
|
if (thermostat.system_type2.reported[mode].stages !== null) {
|
||||||
|
return thermostat.system_type2.reported[mode].stages;
|
||||||
|
} else if (thermostat.system_type2.detected[mode].stages !== null) {
|
||||||
|
return thermostat.system_type2.detected[mode].stages;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'unknown';
|
||||||
|
};
|
||||||
|
@ -30,17 +30,18 @@ beestat.component.card.my_home.prototype.decorate_system_type_ = function(parent
|
|||||||
|
|
||||||
(new beestat.component.title('System')).render(parent);
|
(new beestat.component.title('System')).render(parent);
|
||||||
|
|
||||||
var heat = thermostat_group.system_type_heat !== null
|
const heat = beestat.thermostat.get_system_type(
|
||||||
? thermostat_group.system_type_heat
|
thermostat.thermostat_id,
|
||||||
: 'unknown';
|
'heat'
|
||||||
|
);
|
||||||
var heat_auxiliary = thermostat_group.system_type_heat_auxiliary !== null
|
const heat_auxiliary = beestat.thermostat.get_system_type(
|
||||||
? thermostat_group.system_type_heat_auxiliary
|
thermostat.thermostat_id,
|
||||||
: 'unknown';
|
'heat_auxiliary'
|
||||||
|
);
|
||||||
var cool = thermostat_group.system_type_cool !== null
|
const cool = beestat.thermostat.get_system_type(
|
||||||
? thermostat_group.system_type_cool
|
thermostat.thermostat_id,
|
||||||
: 'unknown';
|
'cool'
|
||||||
|
);
|
||||||
|
|
||||||
var button_group = new beestat.component.button_group();
|
var button_group = new beestat.component.button_group();
|
||||||
button_group.add_button(new beestat.component.button()
|
button_group.add_button(new beestat.component.button()
|
||||||
|
@ -56,7 +56,10 @@ beestat.component.modal.change_system_type.prototype.decorate_contents_ = functi
|
|||||||
for (let key in options) {
|
for (let key in options) {
|
||||||
(new beestat.component.title(titles[key])).render(parent);
|
(new beestat.component.title(titles[key])).render(parent);
|
||||||
|
|
||||||
let current_type = thermostat_group['system_type_' + key];
|
let current_type = beestat.thermostat.get_system_type(
|
||||||
|
thermostat.thermostat_id,
|
||||||
|
key
|
||||||
|
);
|
||||||
|
|
||||||
let button_group = new beestat.component.button_group();
|
let button_group = new beestat.component.button_group();
|
||||||
options[key].forEach(function(system_type) {
|
options[key].forEach(function(system_type) {
|
||||||
|
@ -170,10 +170,10 @@ beestat.layer.load.prototype.decorate_ = function(parent) {
|
|||||||
beestat.setting('temperature_unit', thermostat.temperature_unit);
|
beestat.setting('temperature_unit', thermostat.temperature_unit);
|
||||||
|
|
||||||
// Rename series if only one stage is available.
|
// Rename series if only one stage is available.
|
||||||
if (ecobee_thermostat.settings.coolStages === 1) {
|
if (beestat.thermostat.get_stages(thermostat.thermostat_id, 'cool') === 1) {
|
||||||
beestat.series.sum_compressor_cool_1.name = 'Cool';
|
beestat.series.sum_compressor_cool_1.name = 'Cool';
|
||||||
}
|
}
|
||||||
if (ecobee_thermostat.settings.heatStages === 1) {
|
if (beestat.thermostat.get_stages(thermostat.thermostat_id, 'heat') === 1) {
|
||||||
beestat.series.sum_compressor_heat_1.name = 'Heat';
|
beestat.series.sum_compressor_heat_1.name = 'Heat';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user