Page 1 of 1

Violation errors console

Posted: Sunday 24 December 2023 20:43
by michelscholte
My Dashticz is very slow since a few weeks. I run it on a newly Samsung Tablet. Clickinh on a button takes seconds before Domoticz notice it.
Websocket is working, so that's not the problem.
When I open Dashticz on my pc, I'm getting a lot of "Violation" messages in the console of Chrome and I tink thats yhe reason of the slow tablet.

Anybody any idea what the "Violation" messages might be?
Knipsel.JPG
Knipsel.JPG (49.91 KiB) Viewed 2418 times

Re: Violation errors console

Posted: Monday 25 December 2023 11:42
by gizmocuz
"My Dashticz is very slow since a few weeks. I run it on a newly Samsung Tablet"

Okey, are you able to run it on the thing you previously used to see if that is faster?

Re: Violation errors console

Posted: Monday 25 December 2023 12:02
by michelscholte
Thanks for you reply.

I have the tablet Samsung Tab A8 for about 3 months. In the beginning it was really fast.
As I said, the errors are in Chrome on a Windos PC. I have a lot of them. Domoticz itself runs on an Rasp4.

Re: Violation errors console

Posted: Monday 25 December 2023 12:59
by Lokonli
Maybe first try with a dashboard that only contains one switch, without custom.js and check whether that performs normally.
You can create a new config file, for instance test.js, and load it with /?cfg=test.js

If Dashticz has good performance with the test config file, switch back to your current config and check the following :

Did you configure a block with a low refresh value?
Any functionality in custom.js that may make things slowly? (post it here)


Verzonden vanaf mijn iPhone met Tapatalk

Re: Violation errors console

Posted: Friday 29 December 2023 22:23
by michelscholte
I think I found the problem. It is what you suggested a custom.js problem. I will display and hide blocks depending of the status and combination of the statuses of other blocks. Therefor I use the function "afterGetDevices()". When I delete this function with all the checks from my custom.js the errors are gone.

For example, if the radio is turned on, it shows me the "radio-blocks" and if the radio is off and the tv is on then it shows the "TV-blocks". See below:
radio.JPG
radio.JPG (30.07 KiB) Viewed 2304 times
tv.JPG
tv.JPG (27.47 KiB) Viewed 2304 times
I've attached the custom.js also. Hopefully there is a better way to show and hide these blocks?

Thanks in forward.

Re: Violation errors console

Posted: Friday 29 December 2023 23:53
by Lokonli
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.

Re: Violation errors console

Posted: Saturday 30 December 2023 19:22
by michelscholte
Thanks a lot. I tried it and it works great. I have some work to do :).

One question. Is it also possible, for example, to greyed out the underlying col-data of a block? See picture below:

tv2.JPG
tv2.JPG (49.2 KiB) Viewed 2270 times

Thank for your great effort.

Re: Violation errors console

Posted: Saturday 30 December 2023 20:06
by Lokonli
michelscholte wrote: Saturday 30 December 2023 19:22 Thanks a lot. I tried it and it works great. I have some work to do :).

One question. Is it also possible, for example, to greyed out the underlying col-data of a block? See picture below:


tv2.JPG


Thank for your great effort.
Everything is possible :)

However, I don't understand your question.

'Zender' is a selector switch I guess. Can you post the block definition?
You want to have it greyed out? It look greyed out already... (The selection box with 'Selecteer' inside)

Re: Violation errors console

Posted: Saturday 30 December 2023 20:34
by michelscholte
"Zender" is a selector switch indeed. I want to greyed out it (opacity: 0.4) if the "Input" switch is not TV (in the screendump, for example "Netflix" is selected).

I don't want to greyed out (opacity: 0.4) the block itself, but only col-data.

What you see is exactly what I want but I have to reconfigure it, to reduce the afterGetDevices function.
tv3.JPG
tv3.JPG (119.28 KiB) Viewed 2253 times

Re: Violation errors console

Posted: Wednesday 03 January 2024 20:25
by Lokonli
Several ways ...

I would adapt the deviceHook function:

Code: Select all

function deviceHook(device) {
  if (device.idx == 2628 || device.idx == 2630) setTVStatus(device);

//start of change
  if (device.idx == 2630)
    if (device.Level == 0) //check your device idx and device level for TV
       Domoticz.setBlock('tv_woonkamer_selectie_zender', {addClass: ''});  //normal input selection
    else Domoticz.setBlock('tv_woonkamer_selectie_zender', {addClass: 'datagrayedout'});  //input selection should be grayed
//end of change 

}
and in custom.css:

Code: Select all

.datagrayedout .col-data {
   opacity: 0.4;
}