Upgrading openHAB: best practise to monitor previously installed Marketplace add-ons

Thanks a lot!

from what I read here i assumed, it was done deliberately:

this works just fine! Thanks!

(just a few simple changes:)

var expected = [ "Ephemeris Binding", "The Doctor Binding helps find issues with your system"];
var url = 'http://myohaddress:8080/rest/addons?serviceId=marketplace';
var headers = { "accept": "application/json",
                "Authorization": "Bearer oh.APIToken.UjC...",
                "WWW-Authenticate": "Basic"};
var allAddons = JSON.parse(actions.HTTP.sendHttpGetRequest(url, headers, 2000)); // probably should do some error checking here
var installed = allAddons.filter(addon => addon.installed == true).map(addon => addon.label); // array of the labels of the installed marketplace addons
var missing = expected.filter(addon => !installed.includes(addon));
var unexpected = installed.filter(addon => !expected.includes(addon));
var message = "";
if(missing.length > 0) {
 message = "The following expected marketplace add-ons are not installed: " + missing.join(', ');
}
if(unexpected.length > 0) {
  if(message !== "") message += '\n';
  message +="The following unexpected add-ons from the marketplace are installed: " + unexpected.join(', ');
}
if(message != "") {
  // generate alert
}
console.info("INFO check: ", message);
1 Like