1
0
mirror of https://github.com/beestat/app.git synced 2025-05-24 02:14:03 -04:00

Migrating from system_type2 to system_type

This commit is contained in:
Jon Ziebell 2021-02-21 20:32:18 -05:00
parent 6d359de3ca
commit e4b241666f
5 changed files with 44 additions and 44 deletions

View File

@ -236,9 +236,9 @@ class ecobee_thermostat extends cora\crud {
$attributes['time_zone'] = $this->get_time_zone($thermostat, $ecobee_thermostat);
$attributes['program'] = $this->get_program($thermostat, $ecobee_thermostat);
$detected_system_type2 = $this->get_detected_system_type2($thermostat, $ecobee_thermostat);
if($thermostat['system_type2'] === null) {
$attributes['system_type2'] = [
$detected_system_type = $this->get_detected_system_type($thermostat, $ecobee_thermostat);
if($thermostat['system_type'] === null) {
$attributes['system_type'] = [
'reported' => [
'heat' => [
'equipment' => null,
@ -257,27 +257,27 @@ class ecobee_thermostat extends cora\crud {
'stages' => null
]
],
'detected' => $detected_system_type2
'detected' => $detected_system_type
];
} else {
$attributes['system_type2'] = [
'reported' => $thermostat['system_type2']['reported'],
'detected' => $detected_system_type2
$attributes['system_type'] = [
'reported' => $thermostat['system_type']['reported'],
'detected' => $detected_system_type
];
// TODO This is temporary.
$attributes['system_type2']['reported']['auxiliary_heat'] = $attributes['system_type2']['reported']['heat_auxiliary'];
$attributes['system_type']['reported']['auxiliary_heat'] = $attributes['system_type']['reported']['heat_auxiliary'];
}
$attributes['running_equipment'] = $this->get_running_equipment(
$thermostat,
$ecobee_thermostat,
$attributes['system_type2']
$attributes['system_type']
);
$attributes['alerts'] = $this->get_alerts(
$thermostat,
$ecobee_thermostat,
$attributes['system_type2']
$attributes['system_type']
);
$this->api(
@ -693,7 +693,7 @@ class ecobee_thermostat extends cora\crud {
*
* @return array System type for each of heat, cool, and aux.
*/
private function get_detected_system_type2($thermostat, $ecobee_thermostat) {
private function get_detected_system_type($thermostat, $ecobee_thermostat) {
$detected_system_type = [];
$settings = $ecobee_thermostat['settings'];

View File

@ -123,26 +123,26 @@ class profile extends cora\api {
// Get some stuff
$thermostat = $this->api('thermostat', 'get', $thermostat_id);
if($thermostat['system_type2']['reported']['heat']['equipment'] !== null) {
$system_type_heat = $thermostat['system_type2']['reported']['heat']['equipment'];
if($thermostat['system_type']['reported']['heat']['equipment'] !== null) {
$system_type_heat = $thermostat['system_type']['reported']['heat']['equipment'];
} else {
$system_type_heat = $thermostat['system_type2']['detected']['heat']['equipment'];
$system_type_heat = $thermostat['system_type']['detected']['heat']['equipment'];
}
if($thermostat['system_type2']['reported']['cool']['equipment'] !== null) {
$system_type_cool = $thermostat['system_type2']['reported']['cool']['equipment'];
if($thermostat['system_type']['reported']['cool']['equipment'] !== null) {
$system_type_cool = $thermostat['system_type']['reported']['cool']['equipment'];
} else {
$system_type_cool = $thermostat['system_type2']['detected']['cool']['equipment'];
$system_type_cool = $thermostat['system_type']['detected']['cool']['equipment'];
}
if($thermostat['system_type2']['reported']['heat']['stages'] !== null) {
$heat_stages = $thermostat['system_type2']['reported']['heat']['stages'];
if($thermostat['system_type']['reported']['heat']['stages'] !== null) {
$heat_stages = $thermostat['system_type']['reported']['heat']['stages'];
} else {
$heat_stages = $thermostat['system_type2']['detected']['heat']['stages'];
$heat_stages = $thermostat['system_type']['detected']['heat']['stages'];
}
if($thermostat['system_type2']['reported']['cool']['stages'] !== null) {
$cool_stages = $thermostat['system_type2']['reported']['cool']['stages'];
if($thermostat['system_type']['reported']['cool']['stages'] !== null) {
$cool_stages = $thermostat['system_type']['reported']['cool']['stages'];
} else {
$cool_stages = $thermostat['system_type2']['detected']['cool']['stages'];
$cool_stages = $thermostat['system_type']['detected']['cool']['stages'];
}
@ -273,8 +273,8 @@ class profile extends cora\api {
// Normalizing heating and cooling a bit.
if(
$thermostat['system_type2']['detected']['heat']['equipment'] === 'compressor' ||
$thermostat['system_type2']['detected']['heat']['equipment'] === 'geothermal'
$thermostat['system_type']['detected']['heat']['equipment'] === 'compressor' ||
$thermostat['system_type']['detected']['heat']['equipment'] === 'geothermal'
) {
if($row['compressor_mode'] === 'heat') {
$row['heat_1'] = $row['compressor_1'];

View File

@ -48,17 +48,17 @@ class thermostat extends cora\crud {
private function get_generated_columns($attributes) {
$generated_columns = [];
if(isset($attributes['system_type2']) === true) {
if(isset($attributes['system_type']) === true) {
foreach(['heat', 'heat_auxiliary', 'auxiliary_heat', 'cool'] as $mode) {
if($attributes['system_type2']['reported'][$mode]['equipment'] !== null) {
$generated_columns['system_type_' . $mode] = $attributes['system_type2']['reported'][$mode]['equipment'];
if($attributes['system_type']['reported'][$mode]['equipment'] !== null) {
$generated_columns['system_type_' . $mode] = $attributes['system_type']['reported'][$mode]['equipment'];
} else {
$generated_columns['system_type_' . $mode] = $attributes['system_type2']['detected'][$mode]['equipment'];
$generated_columns['system_type_' . $mode] = $attributes['system_type']['detected'][$mode]['equipment'];
}
if($attributes['system_type2']['reported'][$mode]['stages'] !== null) {
$generated_columns['system_type_' . $mode . '_stages'] = $attributes['system_type2']['reported'][$mode]['stages'];
if($attributes['system_type']['reported'][$mode]['stages'] !== null) {
$generated_columns['system_type_' . $mode . '_stages'] = $attributes['system_type']['reported'][$mode]['stages'];
} else {
$generated_columns['system_type_' . $mode . '_stages'] = $attributes['system_type2']['detected'][$mode]['stages'];
$generated_columns['system_type_' . $mode . '_stages'] = $attributes['system_type']['detected'][$mode]['stages'];
}
}
}
@ -105,7 +105,7 @@ class thermostat extends cora\crud {
foreach($system_types as $system_type => $value) {
if(in_array($system_type, ['heat', 'heat_auxiliary', 'auxiliary_heat', 'cool']) === true) {
$thermostat['system_type2']['reported'][$system_type]['equipment'] = $value;
$thermostat['system_type']['reported'][$system_type]['equipment'] = $value;
}
}

View File

@ -69,10 +69,10 @@ beestat.thermostat.data_synced = function(thermostat_id, required_sync_begin, re
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;
if (thermostat.system_type.reported[mode].equipment !== null) {
return thermostat.system_type.reported[mode].equipment;
} else if (thermostat.system_type.detected[mode].equipment !== null) {
return thermostat.system_type.detected[mode].equipment;
}
return 'unknown';
@ -89,10 +89,10 @@ beestat.thermostat.get_system_type = function(thermostat_id, mode) {
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;
if (thermostat.system_type.reported[mode].stages !== null) {
return thermostat.system_type.reported[mode].stages;
} else if (thermostat.system_type.detected[mode].stages !== null) {
return thermostat.system_type.detected[mode].stages;
}
return 'unknown';

View File

@ -207,7 +207,7 @@ beestat.component.card.system.prototype.decorate_equipment_ = function(parent) {
render_icon(parent, 'fan', beestat.style.color.gray.light);
break;
case 'cool_1':
if (thermostat.system_type2.detected.cool.stages > 1) {
if (thermostat.system_type.detected.cool.stages > 1) {
subscript = '1';
} else {
subscript = undefined;
@ -218,7 +218,7 @@ beestat.component.card.system.prototype.decorate_equipment_ = function(parent) {
render_icon(parent, 'snowflake', beestat.style.color.blue.light, '2');
break;
case 'heat_1':
if (thermostat.system_type2.detected.heat.stages > 1) {
if (thermostat.system_type.detected.heat.stages > 1) {
subscript = '1';
} else {
subscript = undefined;
@ -232,7 +232,7 @@ beestat.component.card.system.prototype.decorate_equipment_ = function(parent) {
render_icon(parent, 'fire', beestat.style.color.orange.base, '3');
break;
case 'auxiliary_heat_1':
if (thermostat.system_type2.detected.auxiliary_heat.stages > 1) {
if (thermostat.system_type.detected.auxiliary_heat.stages > 1) {
subscript = '1';
} else {
subscript = undefined;