diff --git a/caimira/apps/calculator/__init__.py b/caimira/apps/calculator/__init__.py index 0c3505c2..bf25cee6 100644 --- a/caimira/apps/calculator/__init__.py +++ b/caimira/apps/calculator/__init__.py @@ -256,6 +256,10 @@ class ArveData(BaseRequestHandler): client_secret = self.settings['arve_client_secret'] arve_api_key = self.settings['arve_api_key'] + if (client_id == '' or client_secret == '' or arve_api_key == ''): + # If the credentials are not defined, we skip the ARVE API connection + return self.finish('ARVE API credentials not defined.') + http_client = AsyncHTTPClient() URL = 'https://arveapi.auth.eu-central-1.amazoncognito.com/oauth2/token' diff --git a/caimira/apps/calculator/static/js/form.js b/caimira/apps/calculator/static/js/form.js index 6c0525fa..41536425 100644 --- a/caimira/apps/calculator/static/js/form.js +++ b/caimira/apps/calculator/static/js/form.js @@ -312,6 +312,7 @@ function show_sensors_data(url) { url: `${$('#url_prefix').data().calculator_prefix}/api/arve/v1/${HOTEL_ID}/${FLOOR_ID}`, type: 'GET', success: function (result) { + if (result.length == 0) return; // If the ARVE credentials were not defined, we don't have a valid result. DATA_FROM_SENSORS = result; result.map(room => { $("#sensors").append(``);