node-red-contrib-knx-ultimate
Advanced tools
Comparing version
@@ -8,5 +8,5 @@ // Utility function | ||
const dptlib = require('knxultimate').dptlib; | ||
const customHTTP = require('./utils/http'); | ||
// DATAPONT MANIPULATION HELPERS | ||
@@ -65,2 +65,3 @@ // #################### | ||
// 11/03/2020 Delete scene saved file, from html | ||
@@ -91,2 +92,48 @@ RED.httpAdmin.get('/knxultimateCheckHueConnected', (req, res) => { | ||
// // Find all HUE Bridges in the network | ||
// RED.httpAdmin.get('/KNXUltimateDiscoverHueBridges'), (req, res) => { | ||
// const url = 'https://discovery.meethue.com'; // Use HUE broker server discover process by visiting | ||
// async function fetchData() { | ||
// try { | ||
// const response = await fetch(url); // Effettua la richiesta | ||
// const dataArray = await response.json(); // Parsing dei dati JSON | ||
// // Mostra l'array risultante | ||
// res.json(dataArray); | ||
// } catch (error) { | ||
// if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.error(`Error fetching discovery.meethue.com ${error.stack}`); | ||
// res.json(""); | ||
// } | ||
// } | ||
// fetchData(); | ||
// }; | ||
// Find all HUE Bridges in the network | ||
RED.httpAdmin.get('/KNXUltimateGetHueBridgeInfo', RED.auth.needsPermission("hue-config.read"), (req, res) => { | ||
async function fetchData() { | ||
try { | ||
const response = await customHTTP.getBridgeDetails(req.query.IP) | ||
// Mostra l'array risultante | ||
res.json(response); | ||
} catch (error) { | ||
if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.error(`Error fetching discovery.meethue.com ${error.stack}`); | ||
res.json({ error: error.message }); | ||
} | ||
} | ||
fetchData(); | ||
}); | ||
// Find all HUE Bridges in the network | ||
RED.httpAdmin.get('/KNXUltimateGetPlainHueBridgeCredentials', RED.auth.needsPermission("hue-config.read"), (req, res) => { | ||
try { | ||
const serverId = RED.nodes.getNode(req.query.serverId); // Retrieve node.id of the config node. | ||
const username = serverId.credentials.username; | ||
const clientkey = serverId.credentials.clientkey; | ||
res.json({ username: username, clientkey: clientkey }); | ||
} catch (error) { | ||
res.json({ error: error.message }) | ||
} | ||
}); | ||
// Endpoint for connecting to HUE Bridge | ||
@@ -93,0 +140,0 @@ RED.httpAdmin.get("/KNXUltimateRegisterToHueBridge", (req, res) => { |
@@ -103,2 +103,41 @@ /** | ||
return http; | ||
}; | ||
}; | ||
/** | ||
* Get Bridgedetails | ||
* | ||
* @param _ip The target ip. | ||
*/ | ||
module.exports.getBridgeDetails = async (_ip) => { | ||
return new Promise((resolve, reject) => { | ||
const opt = {}; | ||
opt.method = 'GET'; | ||
opt.rejectUnauthorized = false; | ||
opt.url = 'https://' + _ip + '/api/0/config'; | ||
simpleget.concat(opt, (err, res, data) => { | ||
try { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
// log.trace('http data ' + data); | ||
if (res.statusCode >= 100 && res.statusCode < 400) { | ||
try { | ||
let result = JSON.parse(data); | ||
if (result.errors && result.errors.length > 0) { | ||
reject(new Error("The response for " + opt.url + " returned errors " + JSON.stringify(result.errors))); | ||
} | ||
if (!result) { | ||
reject(new Error("Unexpected result with no data. " + JSON.stringify(result))); | ||
} | ||
resolve(result); | ||
} catch (error) { | ||
RED.log.error(`utils.https: config.http.call: let result = JSON.parse(data); =: ${error.message} : ${error.stack || ""} `); | ||
} | ||
} else { | ||
reject(new Error("Error response for " + opt.url + " with status " + res.statusCode + " " + res.statusMessage)); | ||
} | ||
} | ||
} catch (error) { } | ||
}); | ||
}); | ||
}; |
@@ -39,3 +39,3 @@ /* eslint-disable max-len */ | ||
key: this.username, | ||
prefix: `https://${this.hueBridgeIP}/clip/v2`, | ||
prefix: `https://${this.hueBridgeIP}/clip/v2` | ||
}); | ||
@@ -42,0 +42,0 @@ |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "3.1.8", | ||
"version": "3.1.9", | ||
"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": { |
@@ -60,4 +60,4 @@  | ||
* **AUTO RESPONDER node** responds to read requests coming from the bus. Used mainly for virtual group addresses. | ||
* **PHILIPS HUE nodeset** [here](https://github.com/Supergiovane/node-red-contrib-knx-ultimate/wiki/en-hue-configuration). Link HUE devices to KNX in a simple way. | ||
* **HOME ASSISTANT translator node** translates the HA input msg, to a KNX value. Comes with a built-in translation table, that's user editable. | ||
* **PHILIPS HUE nodeset** [here](https://github.com/Supergiovane/node-red-contrib-knx-ultimate/wiki/HUE+Bridge+configuration). Link HUE devices to KNX in a simple way. | ||
* **HOME ASSISTANT translator node** [here](https://github.com/Supergiovane/node-red-contrib-knx-ultimate/wiki/HATranslator) translates the HA input msg, to a KNX value. Comes with a built-in translation table, that's user editable. | ||
@@ -64,0 +64,0 @@ <br> |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
6250465
0.14%10589
0.77%266
-0.37%