|
@@ -5,6 +5,7 @@ module.exports = {
|
|
|
getConfig: getGeneric('getConfig'),
|
|
getConfig: getGeneric('getConfig'),
|
|
|
getFullState: getGeneric('getFullState'),
|
|
getFullState: getGeneric('getFullState'),
|
|
|
getLights: getGeneric('lights'),
|
|
getLights: getGeneric('lights'),
|
|
|
|
|
+ getLight: getLight,
|
|
|
setLight: setLight
|
|
setLight: setLight
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -24,13 +25,21 @@ function init(hueConfig, callback) {
|
|
|
function getGeneric(name) {
|
|
function getGeneric(name) {
|
|
|
return function (req, res) {
|
|
return function (req, res) {
|
|
|
api[name](function (error, result) {
|
|
api[name](function (error, result) {
|
|
|
- if (error) return res.send(500, 'Unable to get t' + name);
|
|
|
|
|
|
|
+ if (error) return res.send(500, 'Unable to get ' + name);
|
|
|
|
|
|
|
|
res.send(200, result);
|
|
res.send(200, result);
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function getLight(req, res) {
|
|
|
|
|
+ api.lightStatus(req.params.id, function (error, result) {
|
|
|
|
|
+ if (error) return res.send(500, 'Unable to get state of light ' + req.params.id);
|
|
|
|
|
+
|
|
|
|
|
+ res.send(200, result);
|
|
|
|
|
+ });
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function setLight(req, res) {
|
|
function setLight(req, res) {
|
|
|
console.log('set light: %s', req.params.id, req.body);
|
|
console.log('set light: %s', req.params.id, req.body);
|
|
|
|
|
|