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']);
|
||||
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) {
|
||||
// Any other error
|
||||
if($this::$log_mysql !== 'all') {
|
||||
|
104
api/runtime.php
104
api/runtime.php
@ -339,59 +339,71 @@ class runtime extends cora\api {
|
||||
*/
|
||||
$begin = floor($begin / 300) * 300;
|
||||
$end = floor($end / 300) * 300;
|
||||
|
||||
$begin_interval = $this->get_interval($begin);
|
||||
$end_interval = $this->get_interval($end);
|
||||
|
||||
$begin_date = date('Y-m-d', $begin);
|
||||
$end_date = date('Y-m-d', $end);
|
||||
|
||||
$response = $this->api(
|
||||
'ecobee',
|
||||
'ecobee_api',
|
||||
[
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'runtimeReport',
|
||||
'arguments' => [
|
||||
'body' => json_encode([
|
||||
'selection' => [
|
||||
'selectionType' => 'thermostats',
|
||||
'selectionMatch' => $ecobee_thermostat['identifier']
|
||||
],
|
||||
'startDate' => $begin_date,
|
||||
'endDate' => $end_date,
|
||||
'startInterval' => $begin_interval,
|
||||
'endInterval' => $end_interval,
|
||||
'columns' => implode(
|
||||
',',
|
||||
[
|
||||
'compCool1', // compressor_1
|
||||
'compCool2', // compressor_2
|
||||
'compHeat1', // compressor_1
|
||||
'compHeat2', // compressor_2
|
||||
'auxHeat1', // auxiliary_heat_1
|
||||
'auxHeat2', // auxiliary_heat_2
|
||||
'fan', // fan
|
||||
'humidifier', // accessory
|
||||
'dehumidifier', // accessory
|
||||
'ventilator', // accessory
|
||||
'economizer', // accessory
|
||||
'hvacMode', // system_mode
|
||||
'zoneAveTemp', // indoor_temperature
|
||||
'zoneHumidity', // indoor_humidity
|
||||
'outdoorTemp', // outdoor_temperature
|
||||
'outdoorHumidity', // outdoor_humidity
|
||||
'zoneCalendarEvent', // event_runtime_thermostat_text_id
|
||||
'zoneClimate', // climate_runtime_thermostat_text_id
|
||||
'zoneCoolTemp', // setpoint_cool
|
||||
'zoneHeatTemp' // setpoint_heat
|
||||
]
|
||||
),
|
||||
'includeSensors' => true
|
||||
])
|
||||
try {
|
||||
$response = $this->api(
|
||||
'ecobee',
|
||||
'ecobee_api',
|
||||
[
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'runtimeReport',
|
||||
'arguments' => [
|
||||
'body' => json_encode([
|
||||
'selection' => [
|
||||
'selectionType' => 'thermostats',
|
||||
'selectionMatch' => $ecobee_thermostat['identifier']
|
||||
],
|
||||
'startDate' => $begin_date,
|
||||
'endDate' => $end_date,
|
||||
'startInterval' => $begin_interval,
|
||||
'endInterval' => $end_interval,
|
||||
'columns' => implode(
|
||||
',',
|
||||
[
|
||||
'compCool1', // compressor_1
|
||||
'compCool2', // compressor_2
|
||||
'compHeat1', // compressor_1
|
||||
'compHeat2', // compressor_2
|
||||
'auxHeat1', // auxiliary_heat_1
|
||||
'auxHeat2', // auxiliary_heat_2
|
||||
'fan', // fan
|
||||
'humidifier', // accessory
|
||||
'dehumidifier', // accessory
|
||||
'ventilator', // accessory
|
||||
'economizer', // accessory
|
||||
'hvacMode', // system_mode
|
||||
'zoneAveTemp', // indoor_temperature
|
||||
'zoneHumidity', // indoor_humidity
|
||||
'outdoorTemp', // outdoor_temperature
|
||||
'outdoorHumidity', // outdoor_humidity
|
||||
'zoneCalendarEvent', // event_runtime_thermostat_text_id
|
||||
'zoneClimate', // climate_runtime_thermostat_text_id
|
||||
'zoneCoolTemp', // setpoint_cool
|
||||
'zoneHeatTemp' // setpoint_heat
|
||||
]
|
||||
),
|
||||
'includeSensors' => true
|
||||
])
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
);
|
||||
} 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);
|
||||
$this->sync_runtime_sensor($thermostat, $response);
|
||||
|
Loading…
x
Reference in New Issue
Block a user