Dashticz.setBlock not working (for me) Topic is solved

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Post Reply
obatavier
Posts: 8
Joined: Saturday 29 August 2020 15:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Dashticz.setBlock not working (for me)

Post by obatavier »

I tried to get the value of Block_19 (Lux) into the title of Block_16 (Temp)

So the title would be like "not 0, but' XXX (were XXX is value of LUX from IDX 19)
I did the following in custom.js but seems nothing happens ?.

function getStatus_19(block) {
var idx = block.idx;
var device = block.device;
Dashticz.setBlock('16', {
title: 'not 0, but ' + device.Level,
});
}
lzwfkv
Posts: 37
Joined: Sunday 11 August 2019 16:54
Target OS: -
Domoticz version:
Contact:

Re: Dashticz.setBlock not working (for me)

Post by lzwfkv »

obatavier wrote: Wednesday 02 September 2020 22:30 I tried to get the value of Block_19 (Lux) into the title of Block_16 (Temp)

So the title would be like "not 0, but' XXX (were XXX is value of LUX from IDX 19)
I did the following in custom.js but seems nothing happens ?.

function getStatus_19(block) {
var idx = block.idx;
var device = block.device;
Dashticz.setBlock('16', {
title: 'not 0, but ' + device.Level,
});
}
It should work: i have tried the code on a couple of devices of mine and it works.
I suspect that the Lux device ((your IDX=19) does not bear a "Level" attribute, therefore, can you try with this change (Level->Data):

Code: Select all

function getStatus_19(block) {
  var idx = block.idx;
  var device = block.device;
        Dashticz.setBlock('16', {
            title: 'not 0, but ' + device.Data,
            });
}
You can check the actual field supported by your sensor by querying Domoticz with:
https://<your domoticz IP>:<your Domoticz port>/json.htm?type=devices&rid=19
obatavier
Posts: 8
Joined: Saturday 29 August 2020 15:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz.setBlock not working (for me)

Post by obatavier »

Hi, thanksit looks like the function is not triggered. (The title never got changed at all)..

I tried with another device (temperature) and which does work in this function.. However it looks like my (Tado) devices for some reason do not provide a value..

I even tried to use a device switch which has values On of Off but
function getStatus_42(block){
var idx = block.idx;
var device = block.device;
if(device['Data']=='Off'){
block.addClass='warninglow';
Dashticz.setBlock('39_1', {
title: 'Heating On',

Seems to never trigger, no matter if I try to change if(device['Data']=='Off') to if(device['Data']=='Anything') no change in behavior.
any idea, looks like it is Tado device (which I checked does have a 'Data' field which is 'Off' or 'On' but no Dashticz updates.

(what I try is to show the temperature of a room (Block 39_1) and change the Title (or better the Icon color but not found that) when the heating of that room is 'On' (Status if device 42))
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz.setBlock not working (for me)

Post by Lokonli »

obatavier wrote: Sunday 04 October 2020 18:31 Hi, thanksit looks like the function is not triggered. (The title never got changed at all)..

I tried with another device (temperature) and which does work in this function.. However it looks like my (Tado) devices for some reason do not provide a value..

I even tried to use a device switch which has values On of Off but
function getStatus_42(block){
var idx = block.idx;
var device = block.device;
if(device['Data']=='Off'){
block.addClass='warninglow';
Dashticz.setBlock('39_1', {
title: 'Heating On',

Seems to never trigger, no matter if I try to change if(device['Data']=='Off') to if(device['Data']=='Anything') no change in behavior.
any idea, looks like it is Tado device (which I checked does have a 'Data' field which is 'Off' or 'On' but no Dashticz updates.

(what I try is to show the temperature of a room (Block 39_1) and change the Title (or better the Icon color but not found that) when the heating of that room is 'On' (Status if device 42))
Did you add device 42 to a column? Otherwise the getStatus function won't get called.

If you defined the block like:

Code: Select all

blocks['myname'] = {
  idx: 42
  }
  
then as function name you should use getStatus_myname

To be sure, please update to latest master or beta.

To make debugging a bit easier, you can add the following statement to the getStatus function:

Code: Select all

console.log(block.device.Data)
In Chrome you can open DevTools by pressing F12. In the console tab you find the log messages (after refreshing Dashticz)
obatavier
Posts: 8
Joined: Saturday 29 August 2020 15:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz.setBlock not working (for me)

Post by obatavier »

Looks like the function does not get triggered (console is empty).. I do have a block with the device,
and I do have triggers with Getstatus who do fire but strange enough not the simple On/Off devices.. ( I would expect when changing the logic like == to != I should see some difference... Maybe a type, a 'or " ?.

(And just to prepare when it triggers How to change only the Icon color of the Dashticz.SetBlock block ?.)
obatavier
Posts: 8
Joined: Saturday 29 August 2020 15:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz.setBlock not working (for me)

Post by obatavier »

I even tried with a ON/Off filed which is currently on my
Dashboard. That one get's updated on the Dashboard from off to on , but the code in custom.js does not even fire on this Device... Not sure why, ..
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz.setBlock not working (for me)

Post by Lokonli »

What is your Dashticz version?

Do you see any other error in DevTools?

Can you post your CONFIG.js and custom.js, then I'll have a look.
obatavier
Posts: 8
Joined: Saturday 29 August 2020 15:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz.setBlock not working (for me)

Post by obatavier »

Hi, first thanks for thinking with me, really appreciated !.

I get a little bit further, seems the Block needs not only to be defined but also visible in a column to work.. in which case the function works for me now.. So I put those blocks safe away under my visible screen.

What I did:
CONFIG.js
blocks[52] = {}
blocks[52]['title'] = 'SheShed_ON';
blocks[52]['width'] = 4;

AND
columns[5]['blocks'] = [32,52]

custom.js
function getStatus_52(block){
var idx = block.idx;
var device = block.device;
if(device['Data']=='On'){
Dashticz.setBlock('49_1', {
title: 'SheShed Heating On',
});

}
}

Well if it works that's fine for me..

Now I need to figure out what to add to get the Icon color (prefer) or Font color Of block '49_1' changed :-)
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz.setBlock not working (for me)

Post by Lokonli »

yes, the block must be added to a column.

With the setBlock function you can also set the addClass parameter.

And then use the class of the addClass parameter in your custom.css to set the color.
obatavier
Posts: 8
Joined: Saturday 29 August 2020 15:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz.setBlock not working (for me)

Post by obatavier »

Hi Lokoni, as A novice with a lot of cut and paste luck, do you have an example how to add the addclass ?

I tried a line like
block.addclass
.addclass
addclass
But none of them were accepted..

Onno
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz.setBlock not working (for me)

Post by Lokonli »

In custom.css:

Code: Select all

.redwarning .col-icon {
    color: red !important;
}
This will make the icon red for blocks with the 'redwarning' class.

In custom.js add the following:

Code: Select all

function getStatus_5(block) {
	var status = block.device.Status;
	if (status === 'On')
		Dashticz.setBlock("7", {addClass: 'redwarning', title:'redwarning title'})
	else
		Dashticz.setBlock("7", {addClass: '', title:'normal title'})
}
In this example I use the Status field of a switch device with idx 5 to set the addClass parameter and title for a device with idx 7, depending on the switch status
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest