|
|
@@ -2,8 +2,9 @@
|
|
|
|
|
|
module.exports = {
|
|
|
init: init,
|
|
|
- getConfig: getConfig,
|
|
|
- getLights: getLights,
|
|
|
+ getConfig: getGeneric('getConfig'),
|
|
|
+ getFullState: getGeneric('getFullState'),
|
|
|
+ getLights: getGeneric('lights'),
|
|
|
setLight: setLight
|
|
|
};
|
|
|
|
|
|
@@ -20,22 +21,14 @@ function init(hueConfig, callback) {
|
|
|
callback();
|
|
|
}
|
|
|
|
|
|
-function getConfig(req, res) {
|
|
|
- api.config(function (error, result) {
|
|
|
- if (error) return res.send(500, 'Unable to connect to bridge');
|
|
|
+function getGeneric(name) {
|
|
|
+ return function (req, res) {
|
|
|
+ api[name](function (error, result) {
|
|
|
+ if (error) return res.send(500, 'Unable to get t' + name);
|
|
|
|
|
|
- res.send(200, result);
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-function getLights(req, res) {
|
|
|
- api.lights(function (error, result) {
|
|
|
- if (error) return res.send(500, error);
|
|
|
-
|
|
|
- console.log('lights:', result);
|
|
|
-
|
|
|
- res.send(200, result);
|
|
|
- });
|
|
|
+ res.send(200, result);
|
|
|
+ });
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
function setLight(req, res) {
|