Dashticz.setBlock not working (for me) Topic is solved
Moderators: leecollings, htilburgs, robgeerts
-
- Posts: 8
- Joined: Saturday 29 August 2020 15:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Dashticz.setBlock not working (for me)
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,
});
}
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,
});
}
Re: Dashticz.setBlock not working (for me)
It should work: i have tried the code on a couple of devices of mine and it works.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,
});
}
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,
});
}
https://<your domoticz IP>:<your Domoticz port>/json.htm?type=devices&rid=19
-
- Posts: 8
- Joined: Saturday 29 August 2020 15:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Dashticz.setBlock not working (for me)
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))
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))
-
- Posts: 2287
- Joined: Monday 29 August 2016 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Dashticz.setBlock not working (for me)
Did you add device 42 to a column? Otherwise the getStatus function won't get called.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))
If you defined the block like:
Code: Select all
blocks['myname'] = {
idx: 42
}
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)
-
- Posts: 8
- Joined: Saturday 29 August 2020 15:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Dashticz.setBlock not working (for me)
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 ?.)
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 ?.)
-
- Posts: 8
- Joined: Saturday 29 August 2020 15:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Dashticz.setBlock not working (for me)
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, ..
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, ..
-
- Posts: 2287
- Joined: Monday 29 August 2016 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Dashticz.setBlock not working (for me)
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.
Do you see any other error in DevTools?
Can you post your CONFIG.js and custom.js, then I'll have a look.
-
- Posts: 8
- Joined: Saturday 29 August 2020 15:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Dashticz.setBlock not working (for me)
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
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

-
- Posts: 2287
- Joined: Monday 29 August 2016 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Dashticz.setBlock not working (for me)
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.
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.
-
- Posts: 8
- Joined: Saturday 29 August 2020 15:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Dashticz.setBlock not working (for me)
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
I tried a line like
block.addclass
.addclass
addclass
But none of them were accepted..
Onno
-
- Posts: 2287
- Joined: Monday 29 August 2016 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Dashticz.setBlock not working (for me)
In custom.css:
This will make the icon red for blocks with the 'redwarning' class.
In custom.js add the following:
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
Code: Select all
.redwarning .col-icon {
color: red !important;
}
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'})
}
Who is online
Users browsing this forum: No registered users and 1 guest