From e4b241666ff1c306cee945c3972d5bc145c4039b Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Sun, 21 Feb 2021 20:32:18 -0500 Subject: [PATCH] Migrating from system_type2 to system_type --- api/ecobee_thermostat.php | 22 +++++++++++----------- api/profile.php | 28 ++++++++++++++-------------- api/thermostat.php | 16 ++++++++-------- js/beestat/thermostat.js | 16 ++++++++-------- js/component/card/system.js | 6 +++--- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/api/ecobee_thermostat.php b/api/ecobee_thermostat.php index 1b08458..0535996 100644 --- a/api/ecobee_thermostat.php +++ b/api/ecobee_thermostat.php @@ -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']; diff --git a/api/profile.php b/api/profile.php index cd0d5af..835915e 100644 --- a/api/profile.php +++ b/api/profile.php @@ -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']; diff --git a/api/thermostat.php b/api/thermostat.php index e1ec2bc..e5d1492 100644 --- a/api/thermostat.php +++ b/api/thermostat.php @@ -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; } } diff --git a/js/beestat/thermostat.js b/js/beestat/thermostat.js index f36c82d..7e976b8 100644 --- a/js/beestat/thermostat.js +++ b/js/beestat/thermostat.js @@ -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'; diff --git a/js/component/card/system.js b/js/component/card/system.js index 764af2b..6400c15 100644 --- a/js/component/card/system.js +++ b/js/component/card/system.js @@ -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;