1
0
mirror of https://github.com/beestat/app.git synced 2025-07-09 03:04:07 -04:00

Fixed #287 - Sync fails if first chunk of data has no viable rows

This commit is contained in:
Jon Ziebell 2020-06-23 22:30:05 -04:00
parent 8caaa185be
commit 1f0d6e267b

View File

@ -92,16 +92,22 @@ class runtime extends cora\api {
1
);
$this->api(
'thermostat',
'update',
[
'attributes' => [
'thermostat_id' => $thermostat_id,
'data_begin' => $runtime_thermostats[0]['timestamp']
// Don't attempt this update if nothing was returned. This can happen
// if data is returned from ecobee for the first time period but none
// of it was valid.
if(count($runtime_thermostats) === 1) {
$this->api(
'thermostat',
'update',
[
'attributes' => [
'thermostat_id' => $thermostat_id,
'data_begin' => $runtime_thermostats[0]['timestamp']
]
]
]
);
);
}
} else {
$this->sync_backwards($thermostat_id);
}