1
0
mirror of https://github.com/beestat/app.git synced 2025-05-24 02:14:03 -04:00

Improved error handling for when no thermostats are found.

This commit is contained in:
Jon Ziebell 2023-04-13 22:41:27 -04:00
parent 8c82cc7e54
commit efbf04d3d4
3 changed files with 49 additions and 37 deletions

View File

@ -198,25 +198,29 @@ class ecobee_sensor extends cora\crud {
}
}
$response = $this->api(
'ecobee',
'ecobee_api',
[
'method' => 'GET',
'endpoint' => 'thermostat',
'arguments' => [
'body' => json_encode([
'selection' => array_merge(
[
'selectionType' => 'thermostats',
'selectionMatch' => implode(',', $serial_numbers),
],
$include
)
])
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
)
])
]
]
]
);
);
} else {
throw $e;
}
} else {
throw $e;
}

View File

@ -161,25 +161,29 @@ class ecobee_thermostat extends cora\crud {
}
}
$response = $this->api(
'ecobee',
'ecobee_api',
[
'method' => 'GET',
'endpoint' => 'thermostat',
'arguments' => [
'body' => json_encode([
'selection' => array_merge(
[
'selectionType' => 'thermostats',
'selectionMatch' => implode(',', $serial_numbers),
],
$include
)
])
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
)
])
]
]
]
);
);
} else {
throw $e;
}
} else {
throw $e;
}

View File

@ -171,7 +171,11 @@ class thermostat extends cora\crud {
return true;
} catch(cora\exception $e) {
return false;
if($e->getCode() === 10511) {
throw $e;
} else {
return false;
}
}
}