[APP][Pro] Better Logic Library - Just some better logic, variable and library management

Indeed, the Watch card uses the homey-api.

Almost everything about the homey-api is heavy on cpu/memory. There are some situationeel that the Watch card is the only available option, but if not, beter use alternative if possible.

BLL coding is done in a Javascript Sandbox (stand-alone engine running the code). So using 6 flowcards to calculate will indeed use more resources than using one flowcard (be it a BLL or HomeyScript flowcard).

BLL coding/expressions uses the same methods as HomeyScript, so singular use would use about the same resources. BLL does add some functions and replaces some possible values (like the checkmark we get instead of true since hp23), so it might use a little bit more cpu when starting the script, but thats real small/low.

@Arie_J_Godschalk, I also thought that BLL used JavaScript quite efficiently. But the difference between the old en new flow is quite large, is this only because of the reduction from 6 to 3 cards (and maybe use of global variable vs BLL variable). I tried 1 single scriptcard, but that became less clean with merging and splitting values. Moreover, no less CPU load (or even more load when getting capabilities inside the script, in stead of as argument from the flow)

const parts = args[0].split(';');
const faseVarName = parts[0];
const newValue = parseFloat(parts[1]);

let values = JSON.parse(global.get(faseVarName) || '[0,0,0,0,0]');
values.shift();
values.push(Math.abs(newValue));
global.set(faseVarName, JSON.stringify(values));

const result = _.round(_.mean(_.sortBy(values).slice(0, -1)), 2);

return result;

With CPU usage before and after: