Good morning,
I am trying to get the color, brightness and state from a Domoticz virtual device.
Whe brightness and state are working, but can't get the color temp working.
In the debug node, I see:
domoticz/out : msg.payload : Object
object
Battery: 255
Color: object
b: 0
cw: 0
g: 0
m: 2
r: 0
t: 255
ww: 255
Level: 37
RSSI: 12
description: ""
dtype: "Color Switch"
hwid: "4"
id: "00084654"
idx: 2654
name: "Zolder Kantoor Gerrie Spots"
nvalue: 15
stype: "RGBWW"
svalue1: "37"
switchType: "Dimmer"
unit: 1
When I click the Color object and check the path to the ww variable, I see: payload.Color.ww
When using msg.payload.Color.ww in a function as variable, I get an error:
The function I use is:
var colortemp = msg.payload.Color.ww;
What am I doing wrong?
function : (error)
"TypeError: Cannot read property 'ww' of undefined"
My total function:
var idx = msg.payload.idx;
var nvalue = msg.payload.nvalue;
var level = msg.payload.Level * 2.55;
var levelr = level.toFixed();
var colortemp = msg.payload.Color.ww;
msg.payload = {}
if (idx == '2654' && typeof idx !== 'undefined' && idx !== null){
if(nvalue == '0') {
msg.payload.state = 'OFF'
}
if(nvalue >= '1') {
msg.payload.state = 'ON';
msg.payload.brightness = levelr;
msg.payload.color_temp = colortemp;
}
return msg;
}