Skip to content

Commit

Permalink
Further corrected issue where missing outdoor weather breaks sync
Browse files Browse the repository at this point in the history
  • Loading branch information
ziebelje committed Aug 31, 2023
1 parent e5640b8 commit 7c23a14
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
11 changes: 8 additions & 3 deletions api/runtime.php
Expand Up @@ -508,7 +508,7 @@ private function sync_runtime_thermostat($thermostat, $response) {
$columns['HVACmode'] === null ||
$columns['zoneAveTemp'] === null ||
$columns['zoneHumidity'] === null ||
$columns['outdoorTemp'] < -1000 || // #384
($columns['outdoorTemp'] !== null && $columns['outdoorTemp'] < -1000) || // #384
$columns['compHeat1'] === null ||
$columns['compHeat2'] === null ||
$columns['compCool1'] === null ||
Expand Down Expand Up @@ -599,8 +599,13 @@ private function sync_runtime_thermostat($thermostat, $response) {
$data['indoor_temperature'] = $columns['zoneAveTemp'] * 10;
$data['indoor_humidity'] = round($columns['zoneHumidity']);

$data['outdoor_temperature'] = $columns['outdoorTemp'] * 10;
$data['outdoor_humidity'] = round($columns['outdoorHumidity']);
if($columns['outdoorTemp'] !== null) {
$data['outdoor_temperature'] = $columns['outdoorTemp'] * 10;
}

if($columns['outdoorHumidity'] !== null) {
$data['outdoor_humidity'] = round($columns['outdoorHumidity']);
}

// Event
$event_runtime_thermostat_text = $this->api(
Expand Down
19 changes: 15 additions & 4 deletions js/beestat/runtime_thermostat.js
Expand Up @@ -139,7 +139,7 @@ beestat.runtime_thermostat.get_data = function(thermostat_id, range, key) {

// Initialize moving average.
var moving = [];
var moving_count = 15;
var moving_count = 5;

var offset;
for (var i = 0; i < moving_count; i++) {
Expand Down Expand Up @@ -169,7 +169,11 @@ beestat.runtime_thermostat.get_data = function(thermostat_id, range, key) {
var outdoor_temperature_moving = beestat.temperature(
beestat.runtime_thermostat.get_average_(moving, 'outdoor_temperature')
);
data.series.outdoor_temperature.push(outdoor_temperature_moving);
if (runtime_thermostat.outdoor_temperature === null) {
data.series.outdoor_temperature.push(null);
} else {
data.series.outdoor_temperature.push(outdoor_temperature_moving);
}
data.metadata.series.outdoor_temperature.data[current_m.valueOf()] =
beestat.temperature(runtime_thermostat.outdoor_temperature);
data.metadata.series.outdoor_temperature.active = true;
Expand All @@ -178,7 +182,11 @@ beestat.runtime_thermostat.get_data = function(thermostat_id, range, key) {
moving,
'outdoor_humidity'
);
data.series.outdoor_humidity.push(outdoor_humidity_moving);
if (runtime_thermostat.outdoor_humidity === null) {
data.series.outdoor_humidity.push(null);
} else {
data.series.outdoor_humidity.push(outdoor_humidity_moving);
}
data.metadata.series.outdoor_humidity.data[current_m.valueOf()] =
runtime_thermostat.outdoor_humidity;
data.metadata.series.outdoor_humidity.active = true;
Expand Down Expand Up @@ -527,7 +535,10 @@ beestat.runtime_thermostat.get_average_ = function(runtime_thermostats, series_c
var average = 0;
var count = 0;
for (var i = 0; i < runtime_thermostats.length; i++) {
if (runtime_thermostats[i] !== undefined) {
if (
runtime_thermostats[i] !== undefined &&
runtime_thermostats[i][series_code] !== null
) {
average += runtime_thermostats[i][series_code];
count++;
}
Expand Down

0 comments on commit 7c23a14

Please sign in to comment.