Page 1 of 1

Dashticz - afterGetDevices()

Posted: Friday 25 June 2021 10:48
by Doudy
Hello,

I tried following via custom.js

Code: Select all

function afterGetDevices(){
    if (Domoticz.getAllDevices()[78].Data == 'Off') {
            $('.pluie-1h .title').addClass('warningblue');
            $('.pluie-1h .state').addClass('warningblue');
    }
    else {
            $('.pluie-1h .title').removeClass('warningblue');
            $('.pluie-1h .state').removeClass('warningblue');
    }
}
My custom.css

Code: Select all

.warningred {
  color: red !important;
}
.warningorange {
  color: orange !important;
}
.warninggreen {
  color: green !important;
}
.warningblue {
  color: blue !important;
}
My Block

Code: Select all

blocks['pluie-1h'] = { 
	idx: 84,
	width: 2,
	title: '1h',
}
But no result on display

Image

Domoticz device [78]
Image

Where is the problem ?
Thank you
Dashticz V3.8.3 beta
;)

Re: Dashticz - afterGetDevices()

Posted: Wednesday 30 June 2021 11:48
by Doudy
Hello,
Nobody ?

function afterGetDevices still does not work! :?

Re: Dashticz - afterGetDevices()

Posted: Sunday 04 July 2021 8:00
by Doudy
Nobody ?
😥

Re: Dashticz - afterGetDevices()

Posted: Sunday 04 July 2021 8:52
by cornesch
Goodmorning,

Below is an example of how it works for me:
(Instead of Data, use Status)

CUSTOM.JS
if (alldevices[118].Status == 'On') {
$('.block_75 .col-data').addClass('warningblue');
}
else {
$('.block_75 .col-data').removeClass('warningblue');
}

CUSTOM.CSS
.warningblue {
color: green !important;
}

Re: Dashticz - afterGetDevices()

Posted: Sunday 04 July 2021 20:33
by Lokonli
Doudy wrote: Friday 25 June 2021 10:48 Hello,

I tried following via custom.js

Code: Select all

function afterGetDevices(){
    if (Domoticz.getAllDevices()[78].Data == 'Off') {
            $('.pluie-1h .title').addClass('warningblue');
            $('.pluie-1h .state').addClass('warningblue');
    }
    else {
            $('.pluie-1h .title').removeClass('warningblue');
            $('.pluie-1h .state').removeClass('warningblue');
    }
}
My custom.css

Code: Select all

.warningred {
  color: red !important;
}
.warningorange {
  color: orange !important;
}
.warninggreen {
  color: green !important;
}
.warningblue {
  color: blue !important;
}
My Block

Code: Select all

blocks['pluie-1h'] = { 
	idx: 84,
	width: 2,
	title: '1h',
}
But no result on display

Image

Domoticz device [78]
Image

Where is the problem ?
Thank you
Dashticz V3.8.3 beta
;)
You have to add '.block_' to the CSS class selector, so like this:

Code: Select all

function afterGetDevices(){
    if (Domoticz.getAllDevices()[78].Data == 'Off') {
            $('.block_pluie-1h .title').addClass('warningblue');
            $('.block_pluie-1h .state').addClass('warningblue');
    }
    else {
            $('.block_pluie-1h .title').removeClass('warningblue');
            $('.block_pluie-1h .state').removeClass('warningblue');
    }
}

Re: Dashticz - afterGetDevices()

Posted: Monday 05 July 2021 9:05
by Doudy
Lokonli wrote: Sunday 04 July 2021 20:33 You have to add '.block_' to the CSS class selector, so like this:

Code: Select all

function afterGetDevices(){
    if (Domoticz.getAllDevices()[78].Data == 'Off') {
            $('.block_pluie-1h .title').addClass('warningblue');
            $('.block_pluie-1h .state').addClass('warningblue');
    }
    else {
            $('.block_pluie-1h .title').removeClass('warningblue');
            $('.block_pluie-1h .state').removeClass('warningblue');
    }
}
It was the right solution
👍

👏