set color based on value

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Vondee
Posts: 30
Joined: Sunday 12 January 2020 19:06
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: set color based on value

Post by Vondee »

I tried this:

Code: Select all

function getStatus_28(block){
var idx = block.idx;
var device = block.device;
    if (device['Data'] == 'Off') {
        Dashticz.setBlock('462', {
            addClass: 'warningyellow'
            });
    }
    else {
        Dashticz.setBlock('462', {
            addClass: ''
            });
    }
But is seem not to work?
The color of block 462 does not change
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: set color based on value

Post by Lokonli »

Your code looks ok.

How do you handle .warningyellow in custom.css?

Sent from my SM-A320FL using Tapatalk

Vondee
Posts: 30
Joined: Sunday 12 January 2020 19:06
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: set color based on value

Post by Vondee »

Code: Select all

.warningyellow {
   color: Yellow;
}
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: set color based on value

Post by Lokonli »

Device 28 is a switch?
How did you define the block for device 28?
Device 28 must have been added to a column as well.

How did you define block "462" in CONFIG.js?
How did you add it to a column?
Vondee
Posts: 30
Joined: Sunday 12 January 2020 19:06
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: set color based on value

Post by Vondee »

Yes, device 28 is a switch.
In CONFIG.js:

Code: Select all

blocks[28] = {}
blocks[28]['title'] = 'Laders'
blocks[28]['icon'] = 'fas fa-battery-half'
blocks[28]['hide_data'] = 1

blocks[462] = {}
blocks[462]['title'] = "Batterij"
blocks[462]['switch'] = 1
blocks[462]['icon'] = 'fa fa-car'
In the column:

Code: Select all

columns[1]['blocks'] = ['blocktitle_1','graph_337','64_1','332_1','58_1',333,'141_2','141_5',462,498,458,500,68,39,362,36,28]
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: set color based on value

Post by Lokonli »

That all looks fine.

What's your Dashticz version?

Any other class in custom.css that sets a color value?

Sent from my SM-A320FL using Tapatalk

Vondee
Posts: 30
Joined: Sunday 12 January 2020 19:06
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: set color based on value

Post by Vondee »

I still had Dashtics version 2. Upgraded to version 3 and it works. Thanks
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: set color based on value

Post by Lokonli »

Good to hear it's working. Next time the version number will be my first question :)


Sent from my SM-A320FL using Tapatalk

Vondee
Posts: 30
Joined: Sunday 12 January 2020 19:06
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: set color based on value

Post by Vondee »

I tried to use the 'SetBlock' for a dial to change the Title, but that does not work?
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: set color based on value

Post by Lokonli »

Vondee wrote: Monday 14 December 2020 13:38 I tried to use the 'SetBlock' for a dial to change the Title, but that does not work?
setBlock indeed doesn't work for dial blocks.

I'll try to add that in a future update.
Vondee
Posts: 30
Joined: Sunday 12 January 2020 19:06
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: set color based on value

Post by Vondee »

Nice! Looking forward for the update

Thanks
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest