Impressive size of custom.js, especially the afterGetDevices function...
Remember, this function is called at every device change.
That also means a lot of classes are added or removed at every device change.
I can imagine this will make Dashticz somewhat slow.
To make Dashticz faster you could use the deviceHook functionality:
There you know which device is changing, and you only need to update the blocks that depend on this.
I see you make use of a lot of Jquery selections ($) that include wildcards (*). These functions are also expensive. Probably there are ways to make this more efficient.
Some ideas:
Line 4:
Code: Select all
$('div[data-screenindex="1"] div[class*="block_tv_woonkamer_selectie_input"]').addClass('displaynone');
can probably be replaced with:
Code: Select all
$('.block_tv_woonkamer_selectie_input').addClass('displaynone');
Further, it seems you want to bring a set of blocks to the same state: hidden or visible for instance.
Instead of add classes to every block every time, you could set a css parameter, and make use of that parameter in the css class definitions.
For instance, in custom.css add:
Code: Select all
.tvstatus {
display: var(--tvstatus)
}
In CONFIG.js add this class to every block that should follow this tvstatus:
Code: Select all
blocks["tv_woonkamer_selectie_input"] = {
...
addClass: 'tvstatus',
...
}
Then you can set the tvstatus css variable via the deviceHook function:
Code: Select all
function deviceHook(device) {
if (device.idx == 2628 || device.idx == 2630) setTVStatus(device);
}
function setTVStatus(device) {
var device2628=Domoticz.getAllDevices()[2628] || {};
var device2630=Domoticz.getAllDevices()[2630] || {};
if (device.idx==2628) device2628=device;
if (device.idx==2630) device2630=device;
var css_tvstatus='unset';
if (device2628.Data=='On') css_tvstatus='none';
$(':root').css('--tvstatus', css_tvstatus);
}
This will make run Dashticz much faster.