innogy-smarthome-lib
Advanced tools
Comparing version 0.1.11 to 0.1.12
@@ -67,2 +67,6 @@ const inherits = require('util').inherits; | ||
var errorHandler = function (e) { | ||
that.emit('error', e); | ||
}; | ||
return that._initialize().then(function () { | ||
@@ -72,3 +76,6 @@ return that._location().then(function () { | ||
return that._capabilityStates().then(function () { | ||
that._startRealtimeUpdates(); | ||
that._startRealtimeUpdates().then(function () { | ||
}, errorHandler); | ||
return that._device().then(function () { | ||
@@ -80,8 +87,8 @@ return that._deviceStates().then(function () { | ||
return that; | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}, errorHandler); | ||
}, errorHandler); | ||
}, errorHandler); | ||
}, errorHandler); | ||
}, errorHandler); | ||
}, errorHandler); | ||
}; | ||
@@ -161,4 +168,11 @@ | ||
var updateCallback = function (capabilityChanged) { | ||
that.emit("stateChanged", capabilityChanged); | ||
}; | ||
this._checkAuthTimer = setInterval(function () { | ||
that._requestor.checkAuthorization(); | ||
that._capabilityStates(updateCallback).then(function () { | ||
}, function (e) { | ||
that.emit("error", e); | ||
}); | ||
}, 1000 * 60 * 10); | ||
@@ -273,3 +287,3 @@ }; | ||
SmartHome.prototype._capabilityStates = function () { | ||
SmartHome.prototype._capabilityStates = function (callback) { | ||
var that = this; | ||
@@ -283,3 +297,3 @@ var parser = []; | ||
if (cap) { | ||
parser.push(cap.parseConfig(aConfig)); | ||
parser.push(cap.parseConfig(aConfig, callback)); | ||
} | ||
@@ -286,0 +300,0 @@ }); |
@@ -39,3 +39,4 @@ const inherits = require('util').inherits; | ||
Capability.prototype._updateStateByConfigObject = function (aConfigObject) { | ||
Capability.prototype._updateStateByConfigObject = function (aConfigObject, stateChangedCallback) { | ||
var that = this; | ||
var configName = this._getCorrectMetaName(aConfigObject.name); | ||
@@ -49,3 +50,8 @@ | ||
if (aState.name === configName) { | ||
var triggerCallback = aState.value !== aConfigObject.value; | ||
aState.value = aConfigObject.value; | ||
if (triggerCallback && stateChangedCallback) | ||
stateChangedCallback(that); | ||
aState.lastchanged = new Date(aConfigObject.lastchanged); | ||
@@ -61,3 +67,3 @@ found = true; | ||
Capability.prototype.parseConfig = function (config) { | ||
Capability.prototype.parseConfig = function (config, stateChangedCallback) { | ||
Capability.super_.prototype.parseConfig.call(this, config); | ||
@@ -73,3 +79,3 @@ | ||
config.State.forEach(function (aState) { | ||
that._updateStateByConfigObject(aState); | ||
that._updateStateByConfigObject(aState, stateChangedCallback); | ||
}); | ||
@@ -76,0 +82,0 @@ } |
@@ -32,4 +32,2 @@ const inherits = require('util').inherits; | ||
console.log(config); | ||
this.type = config.type; | ||
@@ -36,0 +34,0 @@ this.default = config.default ? config.default : null; |
{ | ||
"name": "innogy-smarthome-lib", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"description": "JavaScript library for the Innogy SmartHome system", | ||
@@ -5,0 +5,0 @@ "main": "./lib/smarthome", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53968
1167