I just realized what you meant here. it was an edit and typo to the main script, just a place holder. have edited it below.
Here is the full script. At the moment i am only executing it from the Run Now
button.
AQI and related data is already stored in an item called JSON_Item_Name
by another script. It can have real values or error. This script extracts the value and checks for Error. if no error, then it will store the values in individual items or else fall back on API to get the values.
'use strict';
var logger = Java.type("org.slf4j.LoggerFactory").getLogger("org.openhab.model.script.Rules");
logger.warn("API_AQI: starting the script")
var Transformation = Java.type("org.openhab.core.transform.actions.Transformation");
var HttpUtil = Java.type("org.openhab.core.model.script.actions.HTTP");
var HashMap = Java.type("java.util.HashMap");
//baseURL to get the AQI values - there are two endpoints with this baseURL - one for the token and other for the AQI itself
var baseUrl = "<API_URL>";
var currentDate = new Date();
var commonHeaders = new HashMap();
commonHeaders.put("Host", "<API_HOST>");
//dayjs library included to format the timestamps in local timezone
(function() {
load('https://cdn.jsdelivr.net/npm/dayjs@1.9.5/dayjs.min.js');
load('https://cdn.jsdelivr.net/npm/dayjs@1.9.5/plugin/utc.js');
dayjs.extend(dayjs_plugin_utc);
})();
//API token is stored in an item for re-use.
var tokenItem = ir.getItem("API_token");
var token = tokenItem.state.toString();
logger.warn("API_AQI: first try to get token from registry: "+token.toString());
var headers = new HashMap(commonHeaders);
//if token is avialble then add it to the headers.
if (token) {
headers.put("authorization", token);
}
//this function is called only if token is not availble - and is used to get the token and store in the item
function performLogin() {
var postData = "email=user@host.com&password=password";
var loginHeaders = new HashMap(commonHeaders);
loginHeaders.put("content-type", "application/x-www-form-urlencoded");
loginHeaders.put("content-length", String(postData.length));
loginHeaders.put("accept-encoding", "gzip");
//get the token from this URL
var loginUrl = "<API_login_URL>";
logger.warn("API_AQI: performing login to get token")
//HTTP GET call to the API
var loginResponse = HttpUtil.sendHttpPostRequest(loginUrl, "application/x-www-form-urlencoded", postData, loginHeaders, 10000);
logger.warn("API_AQI: login response: "+loginResponse.toString());
var loginData = JSON.parse(loginResponse);
var token = loginData.data.token;
logger.warn("API_AQI: token: "+token.toString());
//store the token for later re-use
events.sendCommand(tokenItem,token.toString());
}
//this is the main function to check validity of token and get the AQI value from an API using the token
function apiAQI(location) {
logger.warn("API_AQI: calling API function for location:"+location)
if (token === "NULL" || token === "UNDEF") {
logger.warn("API_AQI: Token not found in items, going for login");
//if token is not found in the item registry, then go for login - call the function above.
performLogin();
tokenItem = ir.getItem("API_token");
token = tokenItem.state.toString();
//recreate the header after the token has been obtained via the API, and stored in the item.
headers.put("authorization", token);
}
else
{ //if token is availble (not NULL and not UNDEF), then go for AQI API
logger.warn("API_AQI: token available, proceeding with getting location details")
}
//add location information to AQI API header
headers.put("loc_id", location);
headers.put("searchtype", "loc_id");
//get the AQI using the API - this is first attempt as we need to check the validity of the stored token
var apiResponse = HttpUtil.sendHttpGetRequest(baseUrl, headers, 10000);
var jsonObject = JSON.parse(apiResponse);
//if the previously stored token is invalid as per API response, get a new token
if (jsonObject.message && jsonObject.message.indexOf("Invalid token") !== -1) {
logger.warn("API_AQI: Invalid Token, going for login");
performLogin();
tokenItem = ir.getItem("API_token");
token = tokenItem.state.toString();
headers.put("authorization", token);
//get the AQI using the API - this is second and final attempt
apiResponse = HttpUtil.sendHttpGetRequest(baseUrl, headers, 10000);
jsonObject = JSON.parse(apiResponse);
}
logger.warn("API_AQI: jsonobject: "+apiResponse.toString());
//process the API response to extract the data from JSON response
var loc_Name = jsonObject.Locations[0].loc_Name || "NA";
var loc_id = jsonObject.Locations[0].loc_id || "NA";
var last_updated_at = jsonObject.Locations[0].last_updated_at || "NA";
//this statement works - its used to extract AQI value from the json response
var sensorData_AQI_Value = Transformation.transform("JSONPATH", "$.Locations[0].AQIComponents[?(@.sensorName == 'AQI')].sensorData",apiResponse) || "NA";
logger.warn("API_AQI: Location Name: " + loc_Name);
logger.warn("API_AQI: Location ID: " + loc_id);
logger.warn("API_AQI: Updated At: " + last_updated_at);
logger.warn("API_AQI: Sensor Data AQI: " + sensorData_AQI_Value);
return {
last_updated_at: last_updated_at,
sensorData_AQI_Value: sensorData_AQI_Value
};
}
function processAQI(index, AQI, datetime, LastUpdated, AQI_itemName, lastUpdated_item_Name, location) {
var newLastUpdated = LastUpdated;
var timeDiff = 0;
if (AQI !== "Error!") {
timeDiff = calculateTimeDifference(newLastUpdated);
//reject stale values of 4 hours or older
if (timeDiff > 4) {
AQI = "NA";
newLastUpdated = "NA";
}
} else {
//if AQI returned value is error, then just assume NA
AQI = "NA";
newLastUpdated = "NA";
}
//since we got error from item, we will attempt to obtain the value from API
if (AQI == "NA") {
logger.warn("API_AQI: going for API")
var API_AQI_data = apiAQI(location);
AQI = API_AQI_data.sensorData_AQI_Value;
newLastUpdated = API_AQI_data.last_updated_at;
}
//send the value as received - either from the JSON_Item_name or the API
events.sendCommand(AQI_itemName, AQI);
events.sendCommand(lastUpdated_item_Name, dayjs(newLastUpdated).local().format());
logger.warn("API_AQI: Finished")
}
//AQI and related data is already stored in an item called JSON_Item_Name by another script. it can have real values or error. this script extracts the value and checks for Error. if no error, then it will store the values in individual items or else fall back on API to get the values. the JSON_item_name has AQI, a datetime value when the value was obtained (irrelevant in rest of this script), last updated time of the AQI value (used to calculated staleness of the data). we also include the corresponding item names within this json structure.
var AQIs = [
// location1
{ AQI: JSON.parse(items["JSON_Item_Name"]).links[0].AQI, datetime: JSON.parse(items["JSON_Item_Name"]).links[0].datetime, LastUpdated: JSON.parse(items["JSON_Item_Name"]).links[0].LastUpdated, AQI_itenName: "AQI_Location1", lastUpdated_item_Name: "ObservationTime_Location1", location: "<location_ID_1>"},
// location2
{ AQI: JSON.parse(items["JSON_Item_Name"]).links[1].AQI, datetime: JSON.parse(items["JSON_Item_Name"]).links[1].datetime, LastUpdated: JSON.parse(items["JSON_Item_Name"]).links[1].LastUpdated, AQI_itenName: "AQI_Location2", lastUpdated_item_Name: "ObservationTime_Location2", location: "<location_ID_2>"},
// location3
{ AQI: JSON.parse(items["JSON_Item_Name"]).links[2].AQI, datetime: JSON.parse(items["JSON_Item_Name"]).links[2].datetime, LastUpdated: JSON.parse(items["JSON_Item_Name"]).links[2].LastUpdated, AQI_itenName: "AQI_Location3", lastUpdated_item_Name: "ObservationTime_Location3", location: "<location_ID_3>"}
];
for (var i = 0; i < 3; i++) {
//this is the main loop that needs to be iterated only 3 times.
var currentAQI = AQIs[i];
logger.warn("API_AQI: Iteration number: "+i)
processAQI(
i,
currentAQI.AQI,
currentAQI.datetime,
currentAQI.LastUpdated,
currentAQI.AQI_itenName,
currentAQI.lastUpdated_item_Name,
currentAQI.location
);
}
here is the log in two diffferent situations. First one where API is invoked - the script executes 6 times within 2 seconds and a single press of the Run Now
. And the second set is when API is not invoked - executed a total of 3 times. I am totally lost here why this is happening.
2023-08-23 14:08:35.473 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: starting the script
2023-08-23 14:08:35.601 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: first try to get token from registry: <<token>>
2023-08-23 14:08:35.602 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 0
2023-08-23 14:08:35.604 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:35.605 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:35.612 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_1
2023-08-23 14:08:35.613 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:35.824 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:35.826 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_1
2023-08-23 14:08:35.827 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_1
2023-08-23 14:08:35.827 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:35.828 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI-IN: 87
2023-08-23 14:08:35.842 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:35.843 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 1
2023-08-23 14:08:35.845 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:35.846 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:35.847 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_2
2023-08-23 14:08:35.848 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:35.953 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:35.955 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_2
2023-08-23 14:08:35.956 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_2
2023-08-23 14:08:35.957 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:35.957 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 48
2023-08-23 14:08:35.960 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:35.961 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 2
2023-08-23 14:08:35.961 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:35.962 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:35.963 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_3
2023-08-23 14:08:35.963 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:36.053 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:36.054 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_3
2023-08-23 14:08:36.055 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_3
2023-08-23 14:08:36.056 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:36.056 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 47
2023-08-23 14:08:36.058 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:36.060 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: starting the script
2023-08-23 14:08:36.118 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: first try to get token from registry: <<token>>
2023-08-23 14:08:36.119 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 0
2023-08-23 14:08:36.120 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:36.120 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:36.121 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_1
2023-08-23 14:08:36.121 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:36.210 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:36.212 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_1
2023-08-23 14:08:36.212 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_1
2023-08-23 14:08:36.213 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:36.213 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 87
2023-08-23 14:08:36.216 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:36.217 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 1
2023-08-23 14:08:36.218 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:36.218 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:36.219 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_2
2023-08-23 14:08:36.219 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:36.308 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:36.309 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_2
2023-08-23 14:08:36.310 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_2
2023-08-23 14:08:36.310 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:36.311 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 48
2023-08-23 14:08:36.313 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:36.315 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 2
2023-08-23 14:08:36.315 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:36.316 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:36.316 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_3
2023-08-23 14:08:36.317 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:36.403 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:36.404 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_3
2023-08-23 14:08:36.405 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_3
2023-08-23 14:08:36.405 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:36.405 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 47
2023-08-23 14:08:36.408 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:36.409 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: starting the script
2023-08-23 14:08:36.457 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: first try to get token from registry: <<token>>
2023-08-23 14:08:36.459 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 0
2023-08-23 14:08:36.460 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:36.460 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:36.461 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_1
2023-08-23 14:08:36.461 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:36.555 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:36.556 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_1
2023-08-23 14:08:36.557 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_1
2023-08-23 14:08:36.557 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:36.558 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 87
2023-08-23 14:08:36.563 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:36.564 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 1
2023-08-23 14:08:36.564 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:36.564 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:36.565 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_2
2023-08-23 14:08:36.565 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:36.650 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:36.651 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_2
2023-08-23 14:08:36.652 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_2
2023-08-23 14:08:36.652 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:36.652 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 48
2023-08-23 14:08:36.654 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:36.655 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 2
2023-08-23 14:08:36.655 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:36.655 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:36.656 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_3
2023-08-23 14:08:36.656 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:36.741 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:36.742 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_3
2023-08-23 14:08:36.742 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_3
2023-08-23 14:08:36.743 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:36.743 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 47
2023-08-23 14:08:36.745 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:36.747 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: starting the script
2023-08-23 14:08:36.796 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: first try to get token from registry: <<token>>
2023-08-23 14:08:36.798 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 0
2023-08-23 14:08:36.798 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:36.799 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:36.799 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_1
2023-08-23 14:08:36.800 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:36.886 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:36.887 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_1
2023-08-23 14:08:36.888 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_1
2023-08-23 14:08:36.888 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:36.889 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 87
2023-08-23 14:08:36.891 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:36.892 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 1
2023-08-23 14:08:36.893 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:36.893 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:36.894 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_2
2023-08-23 14:08:36.894 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:36.977 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:36.978 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_2
2023-08-23 14:08:36.979 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_2
2023-08-23 14:08:36.979 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:36.980 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 48
2023-08-23 14:08:36.982 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:36.982 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 2
2023-08-23 14:08:36.983 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:36.983 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:36.984 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_3
2023-08-23 14:08:36.984 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:37.066 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:37.066 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_3
2023-08-23 14:08:37.067 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_3
2023-08-23 14:08:37.067 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:37.067 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 47
2023-08-23 14:08:37.069 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:37.070 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: starting the script
2023-08-23 14:08:37.120 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: first try to get token from registry: <<token>>
2023-08-23 14:08:37.122 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 0
2023-08-23 14:08:37.122 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:37.123 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:37.123 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_1
2023-08-23 14:08:37.124 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:37.207 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:37.208 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_1
2023-08-23 14:08:37.209 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_1
2023-08-23 14:08:37.210 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:37.210 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 87
2023-08-23 14:08:37.215 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:37.216 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 1
2023-08-23 14:08:37.216 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:37.217 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:37.217 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_2
2023-08-23 14:08:37.217 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:37.303 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:37.305 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_2
2023-08-23 14:08:37.305 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_2
2023-08-23 14:08:37.306 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:37.306 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 48
2023-08-23 14:08:37.308 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:37.309 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 2
2023-08-23 14:08:37.309 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:37.310 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:37.310 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_3
2023-08-23 14:08:37.310 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:37.396 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:37.397 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_3
2023-08-23 14:08:37.397 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_3
2023-08-23 14:08:37.398 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:37.398 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 47
2023-08-23 14:08:37.400 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:37.401 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: starting the script
2023-08-23 14:08:37.436 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: first try to get token from registry: <<token>>
2023-08-23 14:08:37.438 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 0
2023-08-23 14:08:37.438 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:37.439 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:37.439 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_1
2023-08-23 14:08:37.439 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:37.522 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>]}
2023-08-23 14:08:37.523 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_1
2023-08-23 14:08:37.523 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_1
2023-08-23 14:08:37.523 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:37.524 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 87
2023-08-23 14:08:37.526 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:37.526 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 1
2023-08-23 14:08:37.527 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:37.527 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:37.528 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_2
2023-08-23 14:08:37.528 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:37.614 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:37.615 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_2
2023-08-23 14:08:37.616 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_2
2023-08-23 14:08:37.616 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:37.617 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 48
2023-08-23 14:08:37.619 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 14:08:37.620 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 2
2023-08-23 14:08:37.621 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Error value retreived. discarding state values
2023-08-23 14:08:37.622 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: going for API
2023-08-23 14:08:37.622 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: calling API function for location:location_ID_3
2023-08-23 14:08:37.623 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: token available, proceeding with getting location details
2023-08-23 14:08:37.710 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: jsonobject: <<AQI JSON response>>
2023-08-23 14:08:37.712 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location Name: location_name_3
2023-08-23 14:08:37.713 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Location ID: location_ID_3
2023-08-23 14:08:37.714 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Updated At: 23 Aug 2023, 01:56pm
2023-08-23 14:08:37.715 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Sensor Data AQI: 47
2023-08-23 14:08:37.718 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished```
2023-08-23 13:53:02.567 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: starting the script
2023-08-23 13:53:02.963 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: first try to get token from registry: <<token>>
2023-08-23 13:53:03.129 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 0
2023-08-23 13:53:03.147 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Non Error values retreived. Not invoking API
2023-08-23 13:53:03.486 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 13:53:03.487 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 1
2023-08-23 13:53:03.489 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Non Error values retreived. Not invoking API
2023-08-23 13:53:03.506 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 13:53:03.507 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 2
2023-08-23 13:53:03.508 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Non Error values retreived. Not invoking API
2023-08-23 13:53:03.513 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 13:53:03.515 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: starting the script
2023-08-23 13:53:03.575 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: first try to get token from registry: <<token>>
2023-08-23 13:53:03.581 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 0
2023-08-23 13:53:03.583 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Non Error values retreived. Not invoking API
2023-08-23 13:53:03.588 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 13:53:03.589 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 1
2023-08-23 13:53:03.589 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Non Error values retreived. Not invoking API
2023-08-23 13:53:03.591 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 13:53:03.592 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 2
2023-08-23 13:53:03.592 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Non Error values retreived. Not invoking API
2023-08-23 13:53:03.594 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 13:53:03.595 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: starting the script
2023-08-23 13:53:03.651 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: first try to get token from registry: <<token>>
2023-08-23 13:53:03.653 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 0
2023-08-23 13:53:03.654 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Non Error values retreived. Not invoking API
2023-08-23 13:53:03.660 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 13:53:03.661 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 1
2023-08-23 13:53:03.662 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Non Error values retreived. Not invoking API
2023-08-23 13:53:03.664 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished
2023-08-23 13:53:03.665 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Iteration number: 2
2023-08-23 13:53:03.665 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Non Error values retreived. Not invoking API
2023-08-23 13:53:03.667 [WARN ] [org.openhab.model.script.Rules ] - API_AQI: Finished