mirror of
https://github.com/beestat/app.git
synced 2025-07-09 03:04:07 -04:00
Allowed outdoor temperature/humidity to be null in runtime_thermostat_summary
Since runtime_thermostat is now allowing null values for these fields, the summary table also has to allow null values for when there is no weather data for the entire time period.
This commit is contained in:
parent
7c23a14247
commit
5dd2e0ed37
@ -491,10 +491,10 @@ CREATE TABLE `runtime_thermostat_summary` (
|
||||
`sum_economizer` mediumint unsigned NOT NULL,
|
||||
`sum_heating_degree_days` smallint unsigned NOT NULL,
|
||||
`sum_cooling_degree_days` smallint unsigned NOT NULL,
|
||||
`avg_outdoor_temperature` smallint NOT NULL,
|
||||
`avg_outdoor_humidity` tinyint unsigned NOT NULL,
|
||||
`min_outdoor_temperature` smallint NOT NULL,
|
||||
`max_outdoor_temperature` smallint NOT NULL,
|
||||
`avg_outdoor_temperature` smallint NULL,
|
||||
`avg_outdoor_humidity` tinyint unsigned NULL,
|
||||
`min_outdoor_temperature` smallint NULL,
|
||||
`max_outdoor_temperature` smallint NULL,
|
||||
`avg_indoor_temperature` smallint NOT NULL,
|
||||
`avg_indoor_humidity` tinyint unsigned NOT NULL,
|
||||
`deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
|
@ -257,13 +257,20 @@ class runtime_thermostat_summary extends cora\crud {
|
||||
];
|
||||
}
|
||||
|
||||
if($runtime_thermostat['outdoor_temperature'] !== null) {
|
||||
$runtime_thermostat['outdoor_temperature'] *= 10;
|
||||
}
|
||||
|
||||
$runtime_thermostat['indoor_temperature'] *= 10;
|
||||
|
||||
$data[$date]['count']++;
|
||||
$data[$date]['sum_fan'] += $runtime_thermostat['fan'];
|
||||
|
||||
if ($runtime_thermostat['outdoor_temperature'] !== null) {
|
||||
$data[$date]['min_outdoor_temperature'] = min($runtime_thermostat['outdoor_temperature'], $data[$date]['min_outdoor_temperature']);
|
||||
$data[$date]['max_outdoor_temperature'] = max($runtime_thermostat['outdoor_temperature'], $data[$date]['max_outdoor_temperature']);
|
||||
}
|
||||
|
||||
$data[$date]['sum_auxiliary_heat_1'] += $runtime_thermostat['auxiliary_heat_1'];
|
||||
$data[$date]['sum_auxiliary_heat_2'] += $runtime_thermostat['auxiliary_heat_2'];
|
||||
|
||||
@ -314,8 +321,26 @@ class runtime_thermostat_summary extends cora\crud {
|
||||
|
||||
// Write to the database.
|
||||
foreach($data as $date => &$row) {
|
||||
if (count($row['avg_outdoor_temperature']) > 0) {
|
||||
$row['avg_outdoor_temperature'] = round(array_sum($row['avg_outdoor_temperature']) / count($row['avg_outdoor_temperature']));
|
||||
} else {
|
||||
$row['avg_outdoor_temperature'] = null;
|
||||
}
|
||||
|
||||
if (count($row['avg_outdoor_humidity']) > 0) {
|
||||
$row['avg_outdoor_humidity'] = round(array_sum($row['avg_outdoor_humidity']) / count($row['avg_outdoor_humidity']));
|
||||
} else {
|
||||
$row['avg_outdoor_humidity'] = null;
|
||||
}
|
||||
|
||||
if ($row['min_outdoor_temperature'] === INF) {
|
||||
$row['min_outdoor_temperature'] = null;
|
||||
}
|
||||
|
||||
if ($row['max_outdoor_temperature'] === -INF) {
|
||||
$row['max_outdoor_temperature'] = null;
|
||||
}
|
||||
|
||||
$row['avg_indoor_temperature'] = round(array_sum($row['avg_indoor_temperature']) / count($row['avg_indoor_temperature']));
|
||||
$row['avg_indoor_humidity'] = round(array_sum($row['avg_indoor_humidity']) / count($row['avg_indoor_humidity']));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user