1
0
mirror of https://github.com/beestat/app.git synced 2025-06-03 13:46:54 -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( if(count($serial_numbers) > 0) {
'ecobee', $response = $this->api(
'ecobee_api', 'ecobee',
[ 'ecobee_api',
'method' => 'GET', [
'endpoint' => 'thermostat', 'method' => 'GET',
'arguments' => [ 'endpoint' => 'thermostat',
'body' => json_encode([ 'arguments' => [
'selection' => array_merge( 'body' => json_encode([
[ 'selection' => array_merge(
'selectionType' => 'thermostats', [
'selectionMatch' => implode(',', $serial_numbers), 'selectionType' => 'thermostats',
], 'selectionMatch' => implode(',', $serial_numbers),
$include ],
) $include
]) )
])
]
] ]
] );
); } else {
throw $e;
}
} else { } else {
throw $e; throw $e;
} }

View File

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

View File

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