mirror of
https://github.com/beestat/app.git
synced 2025-07-09 03:04:07 -04:00
Fixed a few sync issues.
This commit is contained in:
parent
d46096e640
commit
bbd050ee94
@ -266,6 +266,22 @@ class ecobee extends external_api {
|
||||
$this->log_mysql($curl_response, true);
|
||||
}
|
||||
throw new cora\exception('User cannot access thermostat.', 10510, false, null, false);
|
||||
} else if (
|
||||
isset($response['status']['message']) === true &&
|
||||
stripos($response['status']['message'], 'Processing error. Error populating API thermostats.') !== false
|
||||
) {
|
||||
// Processing error. Error populating API thermostats. ...
|
||||
|
||||
// Appears to happen when specifying "includeNotificationSettings" in
|
||||
// the /thermostat API call when using a thermostat serial number from
|
||||
// the /homes endpoint. I believe the /homes endpoint is out of date
|
||||
// and errornously returning the thermostat, then asking for the
|
||||
// thermostat, specifically the notification settings, breaks the
|
||||
// ecobee API.
|
||||
if($this::$log_mysql !== 'all') {
|
||||
$this->log_mysql($curl_response, true);
|
||||
}
|
||||
throw new cora\exception('No thermostats found.', 10511, false, null, false);
|
||||
}
|
||||
}
|
||||
else if (isset($response['status']) === true && $response['status']['code'] !== 0) {
|
||||
|
@ -199,25 +199,44 @@ class ecobee_sensor extends cora\crud {
|
||||
}
|
||||
|
||||
if(count($serial_numbers) > 0) {
|
||||
$response = $this->api(
|
||||
'ecobee',
|
||||
'ecobee_api',
|
||||
[
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'thermostat',
|
||||
'arguments' => [
|
||||
'body' => json_encode([
|
||||
'selection' => array_merge(
|
||||
[
|
||||
'selectionType' => 'thermostats',
|
||||
'selectionMatch' => implode(',', $serial_numbers),
|
||||
],
|
||||
$include
|
||||
)
|
||||
])
|
||||
try {
|
||||
$response = $this->api(
|
||||
'ecobee',
|
||||
'ecobee_api',
|
||||
[
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'thermostat',
|
||||
'arguments' => [
|
||||
'body' => json_encode([
|
||||
'selection' => array_merge(
|
||||
[
|
||||
'selectionType' => 'thermostats',
|
||||
'selectionMatch' => implode(',', $serial_numbers),
|
||||
],
|
||||
$include
|
||||
)
|
||||
])
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
);
|
||||
} catch(cora\exception $e) {
|
||||
/**
|
||||
* For some reason, I can get a serial number in the /homes data
|
||||
* and still get no results from the /thermostat endpoint. Likely
|
||||
* due to two data sources not being in sync. Catch that exception
|
||||
* and let the code continue so any existing thermostats still get
|
||||
* inactivated.
|
||||
*
|
||||
* Also have to fabricate the $response a bit.
|
||||
*/
|
||||
if($e->getCode() === 10511) {
|
||||
$response = [
|
||||
'thermostatList' => []
|
||||
];
|
||||
} else {
|
||||
throw new cora\exception($e->getMessage(), $e->getCode(), $e->getReportable(), $e->getExtraInfo(), $e->getRollback());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* At this point, $response will either be populated with results,
|
||||
|
@ -162,25 +162,44 @@ class ecobee_thermostat extends cora\crud {
|
||||
}
|
||||
|
||||
if(count($serial_numbers) > 0) {
|
||||
$response = $this->api(
|
||||
'ecobee',
|
||||
'ecobee_api',
|
||||
[
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'thermostat',
|
||||
'arguments' => [
|
||||
'body' => json_encode([
|
||||
'selection' => array_merge(
|
||||
[
|
||||
'selectionType' => 'thermostats',
|
||||
'selectionMatch' => implode(',', $serial_numbers),
|
||||
],
|
||||
$include
|
||||
)
|
||||
])
|
||||
try {
|
||||
$response = $this->api(
|
||||
'ecobee',
|
||||
'ecobee_api',
|
||||
[
|
||||
'method' => 'GET',
|
||||
'endpoint' => 'thermostat',
|
||||
'arguments' => [
|
||||
'body' => json_encode([
|
||||
'selection' => array_merge(
|
||||
[
|
||||
'selectionType' => 'thermostats',
|
||||
'selectionMatch' => implode(',', $serial_numbers),
|
||||
],
|
||||
$include
|
||||
)
|
||||
])
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
);
|
||||
} catch(cora\exception $e) {
|
||||
/**
|
||||
* For some reason, I can get a serial number in the /homes data
|
||||
* and still get no results from the /thermostat endpoint. Likely
|
||||
* due to two data sources not being in sync. Catch that exception
|
||||
* and let the code continue so any existing thermostats still get
|
||||
* inactivated.
|
||||
*
|
||||
* Also have to fabricate the $response a bit.
|
||||
*/
|
||||
if($e->getCode() === 10511) {
|
||||
$response = [
|
||||
'thermostatList' => []
|
||||
];
|
||||
} else {
|
||||
throw new cora\exception($e->getMessage(), $e->getCode(), $e->getReportable(), $e->getExtraInfo(), $e->getRollback());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* At this point, $response will either be populated with results,
|
||||
|
Loading…
x
Reference in New Issue
Block a user