node-red-contrib-deconz
Advanced tools
Comparing version 0.7.1 to 0.7.2
179
deconz.js
@@ -92,7 +92,21 @@ var request = require('request'); | ||
//status | ||
node.status({ | ||
fill: "green", | ||
shape: "dot", | ||
text: (node.config.state in device.state) ? device.state[node.config.state] : "connected" | ||
}); | ||
if ("state" in device && "reachable" in device.state && device.state.reachable === false) { | ||
node.status({ | ||
fill: "red", | ||
shape: "ring", | ||
text: "not reachable" | ||
}); | ||
} else if ("config" in device && "reachable" in device.config && device.config.reachable === false) { | ||
node.status({ | ||
fill: "red", | ||
shape: "ring", | ||
text: "not reachable" | ||
}); | ||
} else { | ||
node.status({ | ||
fill: "green", | ||
shape: "dot", | ||
text: (node.config.state in device.state) ? device.state[node.config.state] : "connected" | ||
}); | ||
} | ||
@@ -114,12 +128,2 @@ //outputs | ||
// //check if this device exists | ||
// node.server.getDeviceMeta(function(deviceMeta){ | ||
// if (!deviceMeta) { | ||
// node.status({ | ||
// fill: "red", | ||
// shape: "dot", | ||
// text: 'Device not found' | ||
// }); | ||
// } | ||
// }, config.device); | ||
@@ -169,14 +173,2 @@ if (typeof (config.device) == 'string' && config.device.length) { | ||
//check if this device exists | ||
node.server.getDeviceMeta(function(deviceMeta){ | ||
if (!deviceMeta) { | ||
node.status({ | ||
fill: "red", | ||
shape: "dot", | ||
text: 'Device not found' | ||
}); | ||
} | ||
}, config.device); | ||
if (typeof(config.device) == 'string' && config.device.length) { | ||
@@ -194,13 +186,30 @@ node.status({}); //clean | ||
node.status({ | ||
fill: "green", | ||
shape: "dot", | ||
text: (config.state in node.meta.state)?(node.meta.state[config.state]?node.meta.state[config.state]:''):"received", | ||
}); | ||
node.send({ | ||
payload:(config.state in node.meta.state)?node.meta.state[config.state]:node.meta.state, | ||
meta:deviceMeta, | ||
}); | ||
//status | ||
if ("state" in deviceMeta && "reachable" in deviceMeta.state && deviceMeta.state.reachable === false) { | ||
node.status({ | ||
fill: "red", | ||
shape: "ring", | ||
text: "not reachable" | ||
}); | ||
} else if ("config" in deviceMeta && "reachable" in deviceMeta.config && deviceMeta.config.reachable === false) { | ||
node.status({ | ||
fill: "red", | ||
shape: "ring", | ||
text: "not reachable" | ||
}); | ||
} else { | ||
node.status({ | ||
fill: "green", | ||
shape: "dot", | ||
text: (config.state in node.meta.state)?(node.meta.state[config.state]?node.meta.state[config.state]:''):"received", | ||
}); | ||
node.send({ | ||
payload:(config.state in node.meta.state)?node.meta.state[config.state]:node.meta.state, | ||
meta:deviceMeta, | ||
}); | ||
} | ||
node.cleanTimer = setTimeout(function(){ | ||
@@ -247,12 +256,2 @@ node.status({}); //clean | ||
//check if this device exists | ||
node.server.getDeviceMeta(function(deviceMeta){ | ||
if (!deviceMeta) { | ||
node.status({ | ||
fill: "red", | ||
shape: "dot", | ||
text: 'Device not found' | ||
}); | ||
} | ||
}, config.device); | ||
@@ -620,8 +619,25 @@ if (typeof(config.device) == 'string' && config.device.length) { | ||
if (battery) { | ||
node.status({ | ||
fill: (battery >= 20)?((battery >= 50)?"green":"yellow"):"red", | ||
shape: "dot", | ||
text: battery+'%' | ||
}); | ||
//status | ||
if ("state" in device && "reachable" in device.state && device.state.reachable === false) { | ||
node.status({ | ||
fill: "red", | ||
shape: "ring", | ||
text: "not reachable" | ||
}); | ||
} else if ("config" in device && "reachable" in device.config && device.config.reachable === false) { | ||
node.status({ | ||
fill: "red", | ||
shape: "ring", | ||
text: "not reachable" | ||
}); | ||
} else { | ||
node.status({ | ||
fill: (battery >= 20)?((battery >= 50)?"green":"yellow"):"red", | ||
shape: "dot", | ||
text: battery+'%' | ||
}); | ||
} | ||
//outputs | ||
@@ -733,4 +749,6 @@ node.send([ | ||
var serverNode = RED.nodes.getNode(node.server.id); | ||
delete serverNode.items[dataParsed.uniqueid]; | ||
if ("server" in node) { | ||
var serverNode = RED.nodes.getNode(node.server.id); | ||
delete serverNode.items[dataParsed.uniqueid]; | ||
} | ||
} | ||
@@ -765,2 +783,10 @@ } | ||
var config = device.config; | ||
var no_reponse = false; | ||
if (state !== undefined && state['reachable'] !== undefined && state['reachable'] != null && state['reachable'] === false) { | ||
no_reponse = true; | ||
} | ||
if (config !== undefined && config['reachable'] !== undefined && config['reachable'] != null && config['reachable'] === false) { | ||
no_reponse = true; | ||
} | ||
var msg = {}; | ||
@@ -784,2 +810,3 @@ | ||
characteristic.CurrentTemperature = state['temperature']/100; | ||
if (no_reponse) characteristic.CurrentTemperature = "NO_RESPONSE"; | ||
} | ||
@@ -789,2 +816,3 @@ | ||
characteristic.CurrentRelativeHumidity = state['humidity']/100; | ||
if (no_reponse) characteristic.CurrentRelativeHumidity = "NO_RESPONSE"; | ||
} | ||
@@ -794,2 +822,3 @@ | ||
characteristic.CurrentAmbientLightLevel = state['lux']; | ||
if (no_reponse) characteristic.CurrentAmbientLightLevel = "NO_RESPONSE"; | ||
} | ||
@@ -799,2 +828,3 @@ | ||
characteristic.SmokeDetected = state['fire']; | ||
if (no_reponse) characteristic.SmokeDetected = "NO_RESPONSE"; | ||
} | ||
@@ -810,2 +840,3 @@ | ||
else if ([1010,2010,3010,4010,5010].indexOf(state['buttonevent']) >= 0) characteristic.ProgrammableSwitchEvent = 5; | ||
if (no_reponse) characteristic.ProgrammableSwitchEvent = "NO_RESPONSE"; | ||
} | ||
@@ -819,2 +850,3 @@ | ||
characteristic.OutletInUse = state['power']>0?true:false; | ||
if (no_reponse) characteristic.OutletInUse = "NO_RESPONSE"; | ||
} | ||
@@ -824,2 +856,3 @@ | ||
characteristic.LeakDetected = state['water']?1:0; | ||
if (no_reponse) characteristic.LeakDetected = "NO_RESPONSE"; | ||
} | ||
@@ -829,2 +862,3 @@ | ||
characteristic.MotionDetected = state['presence']; | ||
if (no_reponse) characteristic.MotionDetected = "NO_RESPONSE"; | ||
} | ||
@@ -834,2 +868,3 @@ | ||
characteristic.ContactSensorState = state['open']; | ||
if (no_reponse) characteristic.ContactSensorState = "NO_RESPONSE"; | ||
} | ||
@@ -839,2 +874,3 @@ | ||
characteristic.ContactSensorState = state['vibration']; | ||
if (no_reponse) characteristic.ContactSensorState = "NO_RESPONSE"; | ||
} | ||
@@ -844,6 +880,8 @@ | ||
characteristic.On = state['on']; | ||
if (no_reponse) characteristic.On = "NO_RESPONSE"; | ||
} | ||
if (state['bri'] !== undefined){ | ||
characteristic.Brightness = state['bri']/2.55 | ||
characteristic.Brightness = state['bri']/2.55; | ||
if (no_reponse) characteristic.Brightness = "NO_RESPONSE"; | ||
} | ||
@@ -853,6 +891,8 @@ | ||
characteristic.Hue = state['hue']/182; | ||
if (no_reponse) characteristic.Hue = "NO_RESPONSE"; | ||
} | ||
if (state['sat'] !== undefined){ | ||
characteristic.Saturation = state['sat']/2.55 | ||
characteristic.Saturation = state['sat']/2.55; | ||
if (no_reponse) characteristic.Saturation = "NO_RESPONSE"; | ||
} | ||
@@ -864,2 +904,3 @@ | ||
else if (state['ct'] > 500) characteristic.ColorTemperature = 500; | ||
if (no_reponse) characteristic.ColorTemperature = "NO_RESPONSE"; | ||
} | ||
@@ -872,32 +913,6 @@ } | ||
characteristic.StatusLowBattery = parseInt(device.config['battery'])<=15?1:0; | ||
if (no_reponse) characteristic.StatusLowBattery = "NO_RESPONSE"; | ||
} | ||
} | ||
//reachable, can be in state or config | ||
if (state !== undefined) { | ||
if (state['reachable'] !== undefined && state['reachable'] != null) { | ||
if (!state['reachable']) { | ||
if (device.device_type === 'sensors') { | ||
characteristic.StatusFault = 1; | ||
characteristic.StatusActive = false; | ||
} else if (device.device_type === 'lights') { | ||
characteristic.On = "NO_RESPONSE"; | ||
} | ||
} | ||
} | ||
} | ||
if (config !== undefined) { | ||
if (config['reachable'] !== undefined && config['reachable'] != null) { | ||
if (!config['reachable']) { | ||
if (device.device_type === 'sensors') { | ||
characteristic.StatusActive = false; | ||
characteristic.StatusFault = 1; | ||
} else if (device.device_type === 'lights') { | ||
characteristic.On = "NO_RESPONSE"; | ||
} | ||
} | ||
} | ||
} | ||
msg.payload = characteristic; | ||
@@ -904,0 +919,0 @@ return msg; |
@@ -34,3 +34,3 @@ { | ||
}, | ||
"version": "0.7.1" | ||
"version": "0.7.2" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
791098
2718