Skip to content
This repository has been archived by the owner on Dec 28, 2022. It is now read-only.

Commit

Permalink
add hue api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Dec 26, 2019
1 parent 379ffc3 commit 3222d56
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nodes/shepherd.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ module.exports = function (RED) {
}
});

RED.httpAdmin.get('/zigbee-shepherd/hue', RED.auth.needsPermission('zigbee.read'), (req, res) => {
if (shepherdNodes[req.query.id]) {
const devices = shepherdNodes[req.query.id].herdsman.getDevices().filter(d => d.meta.hue).map(d => toJson.deviceToJson(d));
res.status(200).send(JSON.stringify(devices));
} else {
res.status(500).send(`500 Internal Server Error: Unknown Herdsman ID ${req.query.id}`);
}
});

RED.httpAdmin.get('/zigbee-shepherd/groups', RED.auth.needsPermission('zigbee.read'), (req, res) => {
if (shepherdNodes[req.query.id]) {
const groups = shepherdNodes[req.query.id].herdsman.getGroups().map(g => toJson.groupToJson(g));
Expand Down

0 comments on commit 3222d56

Please sign in to comment.