Issue with afterGetDevices function

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Post Reply
damdub
Posts: 38
Joined: Tuesday 31 December 2019 16:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Issue with afterGetDevices function

Post by damdub »

Hello
I'm trying to change the color of a block if the Last_Update of the corresponding domoticz device is greater than 1 hour.

Here is the part of my CONFIG.js

Code: Select all

function afterGetDevices(){
	var device = Domoticz.getAllDevices()['348'];
	if(moment(device['LastUpdate']).unix() < (moment().unix() - (3600))) { 
		Dashticz.setBlock('348', {
			addClass: 'update_timeout'
		});
	}
	else {
		Dashticz.setBlock('348', {
			addClass: 'update_OK'
		});
	}
}
and here is the part of my custom.css

Code: Select all

.update_timeout {
   background: rgba(230, 101, 92, 0.8)!important;
    background-clip: padding-box;
}
.update_OK {
   background: rgba(81, 204, 252, 0.4)!important;
    background-clip: padding-box;
}
Color of the block doesn't change
What am I doing wrong ?

Thank you for your help
damdub
Posts: 38
Joined: Tuesday 31 December 2019 16:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Issue with afterGetDevices function

Post by damdub »

Anybody ? ;-)
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Issue with afterGetDevices function

Post by Lokonli »

That indeed is a bug. I'll make a fix.
damdub
Posts: 38
Joined: Tuesday 31 December 2019 16:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Issue with afterGetDevices function

Post by damdub »

Great
Thank you for your answer
And above all, Thank you for all the work done :-)
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Issue with afterGetDevices function

Post by Lokonli »

damdub wrote: Tuesday 07 February 2023 9:19 Great
Thank you for your answer
And above all, Thank you for all the work done :-)
I've created a fix in latest beta.
Can you test?

(update with git pull)
damdub
Posts: 38
Joined: Tuesday 31 December 2019 16:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Issue with afterGetDevices function

Post by damdub »

Hello
I did update to last beta and after some tests it appears that it is not yet totally working
I noticed that on some blocks it was OK and on some other blocks it wasn't
I noticed that as soon as a "key" parameter is set on a block, update of color is not working (even if this key is not used in custom css)
So for example this is working :

Code: Select all

blocks[348] = {
width: 4,
hide_data : true,
last_update : false,
icon : 'fa-solid fa-house-fire',
protected : true,
batteryThreshold: 100,
}
And this is not working

Code: Select all

blocks[348] = {
key: 'ping_smoke',
width: 4,
hide_data : true,
last_update : false,
icon : 'fa-solid fa-house-fire',
protected : true,
batteryThreshold: 100,
}
Even if "ping_smoke" is not used in custom css file

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

Re: Issue with afterGetDevices function

Post by Lokonli »

Did you try with:

Code: Select all

Dashticz.setBlock('ping_smoke',{addClass: 'xxx'});
or,
define your block as follows:

Code: Select all

blocks['ping_smoke'] = {
idx: 348,
width: 4,
hide_data : true,
last_update : false,
icon : 'fa-solid fa-house-fire',
protected : true,
batteryThreshold: 100,
}
edit: Don't forget to add the idx parameter (I did)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest