node-red-contrib-knx-ultimate
Advanced tools
Comparing version
@@ -11,3 +11,2 @@ /* eslint-disable camelcase */ | ||
const hueColorConverter = require("./utils/colorManipulators/hueColorConverter"); | ||
//const { AsyncObservable } = require("@project-chip/matter-node.js/util"); | ||
@@ -55,5 +54,2 @@ module.exports = (RED) => { | ||
try { | ||
// if (_event.type === "light" || _event.type === "grouped_light") { | ||
// console.log(_event); | ||
// } | ||
if (oClient.handleSendHUE !== undefined) oClient.handleSendHUE(_event); | ||
@@ -74,7 +70,3 @@ } catch (error) { | ||
try { | ||
if (node.hueAllResources === undefined) { | ||
if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.info(`HTTP getting resource from HUE bridge : ${node.name}`); | ||
await node.loadResourcesFromHUEBridge(); | ||
if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.info(`Total HUE resources count : ${node.hueAllResources.length}`); | ||
} | ||
await node.loadResourcesFromHUEBridge(); | ||
} catch (error) { | ||
@@ -128,3 +120,2 @@ node.linkStatus = "disconnected"; | ||
// Functions called from the nodes ---------------------------------------------------------------- | ||
// Query the HUE Bridge to return the resources | ||
@@ -152,3 +143,3 @@ node.loadResourcesFromHUEBridge = async () => { | ||
if (_node.initializingAtStart === true) { | ||
_node.handleSendHUE(_node.currentHUEDevice); // Pass by value | ||
_node.handleSendHUE(oHUEDevice); // Pass by value | ||
} | ||
@@ -190,9 +181,7 @@ } | ||
// Return an array of light belonging to the groupID | ||
node.getAllLightsBelongingToTheGroup = async function getAllLightsBelongingToTheGroup(_groupID, refreshResourcesFromBridge = true) { | ||
node.getAllLightsBelongingToTheGroup = async function getAllLightsBelongingToTheGroup(_groupID) { | ||
if (node.hueAllResources === undefined || node.hueAllResources === null) return; | ||
const retArr = []; | ||
try { | ||
if (refreshResourcesFromBridge === true) { | ||
await node.loadResourcesFromHUEBridge(); | ||
} | ||
await node.loadResourcesFromHUEBridge(); | ||
node.hueAllResources.forEach((res) => { | ||
@@ -207,4 +196,3 @@ if (res.services !== undefined && res.services.length > 0) { | ||
const oLight = node.hueAllResources.filter((a) => a.id === element.rid); | ||
//if (oLight !== null && oLight !== undefined) retArr.push({ groupID: _groupID, light: oLight[0] }); | ||
if (oLight !== null && oLight !== undefined) retArr.push(oLight[0]); | ||
if (oLight !== null && oLight !== undefined) retArr.push({ groupID: _groupID, light: oLight }); | ||
} | ||
@@ -385,42 +373,2 @@ } | ||
/** | ||
* Get average color XY from a light array | ||
* @param {array} _arrayLights - Light array | ||
* @returns { x,y,mirek,brightness } - Object containing all infos | ||
*/ | ||
node.getAverageColorsXYBrightnessAndTemperature = async function getAverageColorsXYBrightnessAndTemperature(_arrayLights) { | ||
let x; let y; let mirek; let brightness; | ||
let countColor = 0, countColor_Temperature = 0, countDimming = 0; | ||
_arrayLights.forEach((element) => { | ||
if (element.color !== undefined && element.color.xy !== undefined) { | ||
if (x === undefined) { x = 0; y = 0; } | ||
x += element.color.xy.x; | ||
y += element.color.xy.y; | ||
countColor += 1; | ||
} | ||
if (element.color_temperature !== undefined && element.color_temperature.mirek !== undefined) { | ||
if (mirek === undefined) mirek = 0; | ||
mirek += element.color_temperature.mirek; | ||
countColor_Temperature += 1; | ||
} | ||
if (element.dimming !== undefined && element.dimming.brightness !== undefined) { | ||
if (brightness === undefined) brightness = 0; | ||
brightness += element.dimming.brightness; | ||
countDimming += 1; | ||
} | ||
}); | ||
// Calculate and return the averages | ||
const retX = countColor === 0 ? undefined : x / countColor; | ||
const retY = countColor === 0 ? undefined : y / countColor; | ||
const retMirek = countColor_Temperature === 0 ? undefined : mirek / countColor_Temperature; | ||
const retBrightness = countDimming === 0 ? undefined : brightness / countDimming; | ||
return { | ||
x: retX, y: retY, mirek: retMirek, brightness: retBrightness | ||
}; | ||
}; | ||
// END functions called from the nodes ---------------------------------------------------------------- | ||
node.addClient = (_Node) => { | ||
@@ -427,0 +375,0 @@ // Update the node hue device, as soon as a node register itself to hue-config nodeClients |
@@ -56,4 +56,3 @@ module.exports.ToBoolean = function ToBoolean(value, _configTranslationNode) { | ||
}; | ||
const DEFAULTTRANSLATIONINPUT = | ||
"on:true\noff:false\nactive:true\ninactive:false\nopen:true\nclosed:false\nclose:false\n1:true\n0:false\ntrue:true\nfalse:false\nhome:true\nnot_home:false\nnormal:false\nviolated:true"; |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "2.4.27", | ||
"version": "2.4.28", | ||
"description": "Control your KNX intallation via Node-Red! A bunch of KNX nodes, with integrated Philips HUE control and ETS group address importer. Easy to use and highly configurable.", | ||
@@ -9,0 +9,0 @@ "dependencies": { |
@@ -53,5 +53,2 @@  | ||
## SUPPORTED TECHNOLOGIES | ||
|Technology|Supported| | ||
@@ -63,5 +60,5 @@ |--|--| | ||
| KNX Secure Routing |  | | ||
| KNX 3rd PARTY IOT API client |  | | ||
| Matter |  | | ||
| KNX 3rd PARTY IOT API |  | | ||
<br/> | ||
@@ -68,0 +65,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
7107994
-0.28%19358
-1.4%330
-0.9%