mirror of
https://github.com/beestat/app.git
synced 2025-07-09 03:04:07 -04:00
Fixed #332 - Sync fails if one of the sync times is during non-existent time
This commit is contained in:
parent
8992ac93fc
commit
d5696ba37f
@ -237,6 +237,19 @@ class ecobee extends external_api {
|
|||||||
$this->api('ecobee_token', 'delete', $ecobee_token['ecobee_token_id']);
|
$this->api('ecobee_token', 'delete', $ecobee_token['ecobee_token_id']);
|
||||||
throw new cora\exception('Ecobee access was revoked by user.', 10508, false, null, false);
|
throw new cora\exception('Ecobee access was revoked by user.', 10508, false, null, false);
|
||||||
}
|
}
|
||||||
|
else if (isset($response['status']) === true && $response['status']['code'] === 3) {
|
||||||
|
if (
|
||||||
|
isset($response['status']['message']) === true &&
|
||||||
|
stripos($response['status']['message'], 'Illegal instant due to time zone offset transition') !== false
|
||||||
|
) {
|
||||||
|
// Processing error. Illegal instant due to time zone offset transition (daylight savings time 'gap'): ...
|
||||||
|
// Happens when you try to use a time that doesn't exist due to daylight savings spring forward
|
||||||
|
if($this::$log_mysql !== 'all') {
|
||||||
|
$this->log_mysql($curl_response, true);
|
||||||
|
}
|
||||||
|
throw new cora\exception('Illegal instant due to time zone offset transition.', 10509, false, null, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (isset($response['status']) === true && $response['status']['code'] !== 0) {
|
else if (isset($response['status']) === true && $response['status']['code'] !== 0) {
|
||||||
// Any other error
|
// Any other error
|
||||||
if($this::$log_mysql !== 'all') {
|
if($this::$log_mysql !== 'all') {
|
||||||
|
@ -339,13 +339,13 @@ class runtime extends cora\api {
|
|||||||
*/
|
*/
|
||||||
$begin = floor($begin / 300) * 300;
|
$begin = floor($begin / 300) * 300;
|
||||||
$end = floor($end / 300) * 300;
|
$end = floor($end / 300) * 300;
|
||||||
|
|
||||||
$begin_interval = $this->get_interval($begin);
|
$begin_interval = $this->get_interval($begin);
|
||||||
$end_interval = $this->get_interval($end);
|
$end_interval = $this->get_interval($end);
|
||||||
|
|
||||||
$begin_date = date('Y-m-d', $begin);
|
$begin_date = date('Y-m-d', $begin);
|
||||||
$end_date = date('Y-m-d', $end);
|
$end_date = date('Y-m-d', $end);
|
||||||
|
|
||||||
|
try {
|
||||||
$response = $this->api(
|
$response = $this->api(
|
||||||
'ecobee',
|
'ecobee',
|
||||||
'ecobee_api',
|
'ecobee_api',
|
||||||
@ -392,6 +392,18 @@ class runtime extends cora\api {
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
} catch (cora\exception $e) {
|
||||||
|
if($e->getCode() === 10509) {
|
||||||
|
// Try the sync again with times that exist. :)
|
||||||
|
return $this->sync_(
|
||||||
|
$thermostat_id,
|
||||||
|
strtotime('-1 hour', $begin),
|
||||||
|
strtotime('+1 hour', $end)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$return = $this->sync_runtime_thermostat($thermostat, $response);
|
$return = $this->sync_runtime_thermostat($thermostat, $response);
|
||||||
$this->sync_runtime_sensor($thermostat, $response);
|
$this->sync_runtime_sensor($thermostat, $response);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user