diff --git a/api/ecobee_sensor.php b/api/ecobee_sensor.php index 1d150f9..84a4522 100644 --- a/api/ecobee_sensor.php +++ b/api/ecobee_sensor.php @@ -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; } diff --git a/api/ecobee_thermostat.php b/api/ecobee_thermostat.php index 7839ac7..a817d65 100644 --- a/api/ecobee_thermostat.php +++ b/api/ecobee_thermostat.php @@ -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; } diff --git a/api/thermostat.php b/api/thermostat.php index f9c1786..807f205 100644 --- a/api/thermostat.php +++ b/api/thermostat.php @@ -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; + } } }