Dashticz, alternative dashboard based on HTML, CSS, jQuery
Moderators: leecollings , htilburgs , robgeerts
Enz0jacco
Posts: 45 Joined: Tuesday 03 March 2020 8:15
Target OS: NAS (Synology & others)
Domoticz version:
Contact:
Post
by Enz0jacco » Saturday 19 December 2020 9:59
hey guys,
i've got the following situation:
I use two user variables which can only be either 'Open' or 'Closed'
I want the background color to change according this status.
I tried the following but my js knowledge is not very good:
Code: Select all
function getStatus_v18(block){
var idx = block.idx;
var device = block.device;
if(parseString(device['Data'])='Open'){
block.addClass='Klepopen';
}
else {
block.addClass='Klepdicht';
}
}
any ideas?
madpatrick
Posts: 659 Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:
Post
by madpatrick » Saturday 19 December 2020 10:11
This is my setup.
in custom.js
Code: Select all
var trigger_207 = false; //Alarm modefunction getStatus_207(block)
function getStatus_207(block) {
var Data = block.device.Data;
var idx = block.idx;
var device = block.device;
if(device['Status']=='On') {
trigger_207 = true;
block.addClass = 'warning1'; // set the addClass parameter for block 207
}
else {
trigger_207 = false;
block.addClass = ''; // reset the addClass parameter for block
}
handleWarning();
}
in custom.css
Code: Select all
.warning1 {
background: rgba(255,0,0,0.6) !important;
background-clip: padding-box;
border: 3px solid white !important;
border-radius: 15px!important;
}
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.14b on Tab8" =-
Lokonli
Posts: 2287 Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:
Post
by Lokonli » Saturday 19 December 2020 12:39
Enz0jacco wrote: ↑ Saturday 19 December 2020 9:59
hey guys,
i've got the following situation:
I use two user variables which can only be either 'Open' or 'Closed'
I want the background color to change according this status.
I tried the following but my js knowledge is not very good:
Code: Select all
function getStatus_v18(block){
var idx = block.idx;
var device = block.device;
if(parseString(device['Data'])='Open'){
block.addClass='Klepopen';
}
else {
block.addClass='Klepdicht';
}
}
any ideas?
The if statement is wrong. Change it to:
Code: Select all
if(parseString(device['Data'])=='Open'){
(The single '=' is an assignment, for comparison use '==')
Enz0jacco
Posts: 45 Joined: Tuesday 03 March 2020 8:15
Target OS: NAS (Synology & others)
Domoticz version:
Contact:
Post
by Enz0jacco » Saturday 19 December 2020 13:35
omg silly me, I could've known that.
unfortunately that was not the only problem.
I think maybe that var device and data is not correct but I'm not sure what it should be as it is a user variable.
Lokonli
Posts: 2287 Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:
Post
by Lokonli » Saturday 19 December 2020 14:20
O yes, indeed.
For variables it's device['Value'] instead of device['Data']
Enz0jacco
Posts: 45 Joined: Tuesday 03 March 2020 8:15
Target OS: NAS (Synology & others)
Domoticz version:
Contact:
Post
by Enz0jacco » Saturday 19 December 2020 14:29
Ok did that and now I think there is something wrong with the getstatus part. I tried to put the v18 between quotes but that doesnt do the trick either.
Lokonli
Posts: 2287 Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:
Post
by Lokonli » Saturday 19 December 2020 15:25
And remove parseString...
Sent from my SM-A320FL using Tapatalk
Enz0jacco
Posts: 45 Joined: Tuesday 03 March 2020 8:15
Target OS: NAS (Synology & others)
Domoticz version:
Contact:
Post
by Enz0jacco » Saturday 19 December 2020 15:41
ah makes sense ! its working perfectly thnx again!
Users browsing this forum: No registered users and 1 guest