Lokonli wrote: Saturday 14 August 2021 11:01
ok, let's restart.
Assuming that in CONFIG.js you use device 42 in a column, or defined a block like:
Code: Select all
blocks[42] = {
title: 'My dimmer',
...
}
Then add the following to custom.js:
Code: Select all
function getStatus_42(block) {
var color = JSON.parse(block.device.Color);
if (block.device.Data != 'Off') {
var yellow = 255;
var blue = 255;
if (color.ww > 128)
//very warm, so reduce blue
blue = 255 - color.ww / 2 + 64;
if (color.cw > 128)
//very cold, so reduce yellow
yellow = 255 - color.cw / 2 + 64;
var colorStr = `rgb(${yellow},${yellow},${blue})`;
$(block.mountPoint + ' > div').css('background-color', colorStr);
} else $(block.mountPoint + ' > div').css('background-color', '');
}
This code is working. It will give the dimmer block in Dashticz a background color of more blue or more yellow, depending on the warm white/cold white slider.
First try to get this working. After that we can change the behavior if needed.
Note: So don't use the afterGetDevices function hook for this. (the block parameter is not known. It's more difficult to find the exact device block in the browser window)
Absolutely awesome! It's working wow
Ok, so if i want to change the slider and slider-button can i use
and another one for the slider-button for this?
Also is it possible to use idx 44 for this? This is a virtual dimmer that has a level from 1-100 where 100 is 100 Kelvin and 1 is 1 Kelvin
This is the JSON output of that virtual dimmer:
Code: Select all
{
"ActTime" : 1628946726,
"AstrTwilightEnd" : "19:55",
"AstrTwilightStart" : "04:50",
"CivTwilightEnd" : "19:03",
"CivTwilightStart" : "05:42",
"DayLength" : "12:36",
"NautTwilightEnd" : "19:28",
"NautTwilightStart" : "05:16",
"ServerTime" : "2021-08-14 20:12:06",
"SunAtSouth" : "12:22",
"Sunrise" : "06:04",
"Sunset" : "18:41",
"app_version" : "2021.1",
"result" :
[
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"CustomImage" : 0,
"Data" : "Set Level: 99 %",
"Description" : "",
"DimmerType" : "abs",
"Favorite" : 1,
"HardwareDisabled" : false,
"HardwareID" : 4,
"HardwareName" : "VirtualSwitches",
"HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
"HardwareTypeVal" : 15,
"HaveDimmer" : true,
"HaveGroupCmd" : true,
"HaveTimeout" : false,
"ID" : "0001407C",
"Image" : "Light",
"IsSubDevice" : false,
"LastUpdate" : "2021-08-14 20:12:00",
"Level" : 99,
"LevelInt" : 99,
"MaxDimLevel" : 100,
"Name" : "Hue",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" :
[
0
],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"Status" : "Set Level: 99 %",
"StrParam1" : "",
"StrParam2" : "",
"SubType" : "Switch",
"SwitchType" : "Dimmer",
"SwitchTypeVal" : 7,
"Timers" : "false",
"Type" : "Light/Switch",
"TypeImg" : "dimmer",
"Unit" : 1,
"Used" : 1,
"UsedByCamera" : false,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "44"
}
],
"status" : "OK",
"title" : "Devices"
}
Maybe i could read the value of idx 42 as it is working now and change the .ui-slider-horizontal (?) color for this?
I calculate the kelvin color in a domoticz dzVents script from cc to input as value for idx 44 as follows;
Code: Select all
colorcalc = math.floor((maxi-delta/2)+(delta/2)*math.cos((now-offset)*2*math.pi/periode)+0.5)
couch.setKelvin(colorcalc)
hue.setLevel(colorcalc)
Where couch is idx42, the Hue lamp and hue is the virtual dimmer that shows the hue color is Kelvin
Then i have one last question. Is it also possible to change the % in this virtual dimmer idx44 to a the letter K? I tried that with the code in CUSTOM.js but it didnt work there. I tried
Code: Select all
blocks[44] = {title: 'Hue', width: 8, unit: 'K', icon: 'fas fa-sun'}
The unit: code isn't working
Sorry for all questions but very happy already wirh this result