Closed bossabode closed 8 years ago
The referenced figaro-api.js file is as below.
`// Fibaro rest api client
'use strict';
var request = require("request");
function FibaroClient(host, username, password) { this.host = "192.168.105.4"; this.username = "admin"; this.password = "admin"; this.auth = "Basic " + new Buffer(this.username + ":" + this.password).toString("base64"); } FibaroClient.prototype.getRooms = function() { var that = this; var p = new Promise(function(resolve, reject) { var url = "http://"+that.host+"/api/rooms"; request.get({ url: url, headers : { "Authorization" : that.auth }, json: true }, function(err, response, json) { if (!err && response.statusCode == 200) resolve(json); else reject(err, response); }); }); return p; } FibaroClient.prototype.getDevices = function() { var that = this; var p = new Promise(function(resolve, reject) { var url = "http://"+that.host+"/api/devices"; request.get({ url: url, headers : { "Authorization" : that.auth }, json: true }, function(err, response, json) { if (!err && response.statusCode == 200) resolve(json); else reject(err, response); }); }); return p; } FibaroClient.prototype.getDeviceProperties = function(ID) { var that = this; var p = new Promise(function(resolve, reject) { var url = "http://"+that.host+"/api/devices/"+ID; request.get({ url: url, headers : { "Authorization" : that.auth }, json: true }, function(err, response, json) { if (!err && response.statusCode == 200) resolve(json.properties); else reject(err, response); }); }); return p; } FibaroClient.prototype.executeDeviceAction = function(ID, action, param) { var that = this; var p = new Promise(function(resolve, reject) { var url = "http://"+that.host+"/api/devices/"+ID+"/action/"+action; var body = param != undefined ? JSON.stringify({ "args": [ param ] }) : null; var method = "post"; request({ url: url, body: body, method: method, headers: { "Authorization" : that.auth } }, function(err, response) { if (!err && (response.statusCode == 200 || response.statusCode == 202)) resolve(response); else reject(err, response); }); }); return p; } FibaroClient.prototype.refreshStates = function(lastPoll) { var that = this; var p = new Promise(function(resolve, reject) { var url = "http://"+that.host +"/api/refreshStates?last=" + lastPoll; request.get({ url: url, headers : { "Authorization" : that.auth }, json: true }, function(err, response, json) { if (!err && response.statusCode == 200) resolve(json); else reject(err, response); }); }); return p; }
module.exports.createClient = function(host, username, password) { return new FibaroClient(host, username, password); } `
which version of node.js do you have?
Thanks for such a quick response ilcato
Node version is v0.10.46
You need a node version 4.0 or up.
Hey Guys,
Hope you can help with this one as I've gotten a little bit stuck.
Home bridge starts then crashes on errors referencing promise.