thing-it-device-wtec
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -116,4 +116,3 @@ "use strict"; | ||
} | ||
] | ||
/*, | ||
], | ||
events: [ | ||
@@ -125,3 +124,2 @@ { | ||
] | ||
*/ | ||
}, | ||
@@ -330,29 +328,39 @@ create: function () { | ||
if (this.state.motion == undefined) { | ||
//init via update | ||
this.state.motion = 0; | ||
this.state.occupancy = 0; | ||
//this.publishEvent(this.events.tic, {motion: this.state.motion, occupancy: this.state.occupancy}); | ||
} else if (this.state.motion === 0) { | ||
//first update via subscription | ||
this.state.motion = response.sensorStats.motion.instant; | ||
if (this.state.motion > (responseTime - this.configuration.motionInterval)) { | ||
this.state.occupancy = 1; | ||
} else { | ||
this.state.occupancy = 0; | ||
if (responseTime != undefined) { | ||
//first update via subscription | ||
this.state.motion = response.sensorStats.motion.instant; | ||
if (this.state.motion > (responseTime - this.configuration.motionInterval)) { | ||
this.state.occupancy = 1; | ||
} else { | ||
this.state.occupancy = 0; | ||
} | ||
try { | ||
this.publishEvent(this.events.tic, { | ||
motion: this.state.motion, | ||
occupancy: this.state.occupancy | ||
}); | ||
} catch (e) { | ||
this.logError('Error publishing Event', e); | ||
} | ||
} | ||
//this.publishEvent(this.events.tic, {motion: this.state.motion, occupancy: this.state.occupancy}); | ||
} else if (response.sensorStats.motion.instant > this.state.motion) { | ||
//all following updates via subscription | ||
if (this.motionTimeout) { | ||
clearTimeout(this.motionTimeout); | ||
} | ||
} else { | ||
if (response.sensorStats.motion.instant > this.state.motion) { | ||
//all following updates via subscription | ||
if (this.motionTimeout) { | ||
clearTimeout(this.motionTimeout); | ||
} | ||
this.motionTimeout = setTimeout(function () { | ||
this.state.occupancy = 0; | ||
this.publishStateChange(); | ||
}.bind(this), this.configuration.motionInterval * 1000); | ||
this.motionTimeout = setTimeout(function () { | ||
this.state.occupancy = 0; | ||
this.publishStateChange(); | ||
}.bind(this), this.configuration.motionInterval * 1000); | ||
this.state.motion = response.sensorStats.motion.instant; | ||
this.state.occupancy = 1; | ||
//this.publishEvent(this.events.tic, {motion: this.state.motion, occupancy: this.state.occupancy}); | ||
this.state.motion = response.sensorStats.motion.instant; | ||
this.state.occupancy = 1; | ||
try { | ||
this.publishEvent(this.events.tic, {motion: this.state.motion, occupancy: this.state.occupancy}); | ||
} catch (e) { | ||
this.logError('Error publishing Event', e); | ||
} | ||
} | ||
} | ||
@@ -359,0 +367,0 @@ } |
@@ -136,5 +136,3 @@ "use strict"; | ||
} | ||
] | ||
/* | ||
, | ||
], | ||
events: [ | ||
@@ -146,3 +144,2 @@ { | ||
] | ||
*/ | ||
}, | ||
@@ -397,6 +394,7 @@ create: function () { | ||
var adjustedTime = currentTime + this.configuration.timeAdjust; | ||
this.logDebug('adjustedTime', adjustedTime); | ||
var promise; | ||
if (this.isSimulated()) { | ||
this.state.brightness = brightness; | ||
this.state.brightness = brightness.value; | ||
this.publishStateChange(); | ||
@@ -414,3 +412,3 @@ this.promise = q(); | ||
"lowLevelControl":{\ | ||
"brightness":' + brightness + ',\ | ||
"brightness":' + brightness.value + ',\ | ||
"activated":' + adjustedTime + '}\ | ||
@@ -427,4 +425,4 @@ }\ | ||
// in case of success, the response does not contain data. | ||
this.logDebug('Successfully set brightness ' + brightness); | ||
this.state.brightness = brightness; | ||
this.logDebug('Successfully set brightness ' + brightness.value); | ||
this.state.brightness = brightness.value; | ||
this.readResponse(response); | ||
@@ -458,29 +456,42 @@ }.bind(this)) | ||
if (this.state.motion == undefined) { | ||
//init via update | ||
this.state.motion = 0; | ||
this.state.occupancy = 0; | ||
//this.publishEvent(this.events.tic, {motion: this.state.motion, occupancy: this.state.occupancy}); | ||
} else if (this.state.motion === 0) { | ||
//first update via subscription | ||
this.state.motion = response.sensorStats.motion.instant; | ||
if (this.state.motion > (responseTime - this.configuration.motionInterval)) { | ||
this.state.occupancy = 1; | ||
} else { | ||
this.state.occupancy = 0; | ||
if (responseTime != undefined) { | ||
//first update via subscription | ||
this.state.motion = response.sensorStats.motion.instant; | ||
if (this.state.motion > (responseTime - this.configuration.motionInterval)) { | ||
this.state.occupancy = 1; | ||
} else { | ||
this.state.occupancy = 0; | ||
} | ||
try { | ||
this.publishEvent(this.events.tic, { | ||
motion: this.state.motion, | ||
occupancy: this.state.occupancy | ||
}); | ||
} catch (e) { | ||
this.logError('Error publishing Event', e); | ||
} | ||
} | ||
//this.publishEvent(this.events.tic, {motion: this.state.motion, occupancy: this.state.occupancy}); | ||
} else if (response.sensorStats.motion.instant > this.state.motion) { | ||
//all following updates via subscription | ||
if (this.motionTimeout) { | ||
clearTimeout(this.motionTimeout); | ||
} | ||
} else { | ||
if (response.sensorStats.motion.instant > this.state.motion) { | ||
//all following updates via subscription | ||
if (this.motionTimeout) { | ||
clearTimeout(this.motionTimeout); | ||
} | ||
this.motionTimeout = setTimeout(function () { | ||
this.state.occupancy = 0; | ||
this.publishStateChange(); | ||
}.bind(this), this.configuration.motionInterval * 1000); | ||
this.motionTimeout = setTimeout(function () { | ||
this.state.occupancy = 0; | ||
this.publishStateChange(); | ||
}.bind(this), this.configuration.motionInterval * 1000); | ||
this.state.motion = response.sensorStats.motion.instant; | ||
this.state.occupancy = 1; | ||
//this.publishEvent(this.events.tic, {motion: this.state.motion, occupancy: this.state.occupancy}); | ||
this.state.motion = response.sensorStats.motion.instant; | ||
this.state.occupancy = 1; | ||
try { | ||
this.publishEvent(this.events.tic, { | ||
motion: this.state.motion, | ||
occupancy: this.state.occupancy | ||
}); | ||
} catch (e) { | ||
this.logError('Error publishing Event', e); | ||
} | ||
} | ||
} | ||
@@ -487,0 +498,0 @@ } |
@@ -110,5 +110,3 @@ "use strict"; | ||
} | ||
] | ||
/* | ||
, | ||
], | ||
events: [ | ||
@@ -120,3 +118,2 @@ { | ||
] | ||
*/ | ||
}, | ||
@@ -313,29 +310,42 @@ create: function () { | ||
if (this.state.motion == undefined) { | ||
//init via update | ||
this.state.motion = 0; | ||
this.state.occupancy = 0; | ||
//this.publishEvent(this.events.tic, {motion: this.state.motion, occupancy: this.state.occupancy}); | ||
} else if (this.state.motion === 0) { | ||
//first update via subscription | ||
this.state.motion = response.sensorStats.motion.instant; | ||
if (this.state.motion > (responseTime - this.configuration.motionInterval)) { | ||
this.state.occupancy = 1; | ||
} else { | ||
this.state.occupancy = 0; | ||
if (responseTime != undefined) { | ||
//first update via subscription | ||
this.state.motion = response.sensorStats.motion.instant; | ||
if (this.state.motion > (responseTime - this.configuration.motionInterval)) { | ||
this.state.occupancy = 1; | ||
} else { | ||
this.state.occupancy = 0; | ||
} | ||
try { | ||
this.publishEvent(this.events.tic, { | ||
motion: this.state.motion, | ||
occupancy: this.state.occupancy | ||
}); | ||
} catch (e) { | ||
this.logError('Error publishing Event', e); | ||
} | ||
} | ||
//this.publishEvent(this.events.tic, {motion: this.state.motion, occupancy: this.state.occupancy}); | ||
} else if (response.sensorStats.motion.instant > this.state.motion) { | ||
//all following updates via subscription | ||
if (this.motionTimeout) { | ||
clearTimeout(this.motionTimeout); | ||
} | ||
} else { | ||
if (response.sensorStats.motion.instant > this.state.motion) { | ||
//all following updates via subscription | ||
if (this.motionTimeout) { | ||
clearTimeout(this.motionTimeout); | ||
} | ||
this.motionTimeout = setTimeout(function () { | ||
this.state.occupancy = 0; | ||
this.publishStateChange(); | ||
}.bind(this), this.configuration.motionInterval * 1000); | ||
this.motionTimeout = setTimeout(function () { | ||
this.state.occupancy = 0; | ||
this.publishStateChange(); | ||
}.bind(this), this.configuration.motionInterval * 1000); | ||
this.state.motion = response.sensorStats.motion.instant; | ||
this.state.occupancy = 1; | ||
//this.publishEvent(this.events.tic, {motion: this.state.motion, occupancy: this.state.occupancy}); | ||
this.state.motion = response.sensorStats.motion.instant; | ||
this.state.occupancy = 1; | ||
try { | ||
this.publishEvent(this.events.tic, { | ||
motion: this.state.motion, | ||
occupancy: this.state.occupancy | ||
}); | ||
} catch (e) { | ||
this.logError('Error publishing Event', e); | ||
} | ||
} | ||
} | ||
@@ -342,0 +352,0 @@ } |
@@ -309,6 +309,7 @@ "use strict"; | ||
var adjustedTime = currentTime + this.configuration.timeAdjust; | ||
this.logDebug('adjustedTime', brightness); | ||
var promise; | ||
if (this.isSimulated()) { | ||
this.state.brightness = brightness; | ||
this.state.brightness = brightness.value; | ||
this.publishStateChange(); | ||
@@ -326,3 +327,3 @@ this.promise = q(); | ||
"lowLevelControl":{\ | ||
"brightness":' + brightness + ',\ | ||
"brightness":' + brightness.value + ',\ | ||
"activated":' + adjustedTime + '}\ | ||
@@ -339,4 +340,4 @@ }\ | ||
// in case of success, the response does not contain data. | ||
this.logDebug('Successfully set brightness ' + brightness); | ||
this.state.brightness = brightness; | ||
this.logDebug('Successfully set brightness ' + brightness.value); | ||
this.state.brightness = brightness.value; | ||
this.readResponse(response); | ||
@@ -343,0 +344,0 @@ }.bind(this)) |
{ | ||
"name": "thing-it-device-wtec", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "[thing-it-node] Device Plugin for wtec devices.", | ||
@@ -5,0 +5,0 @@ "authors": "Klaus Berberich", |
angular.module('testApp', ['ThingItMobile.PluginDirectives']) | ||
.controller('TestController', function () { | ||
this.location = { | ||
_configuration: { | ||
configuration: { | ||
displayOccupancy: true, | ||
@@ -40,3 +40,3 @@ displayPower: true, | ||
console.log('setBrightness received Value', brightness); | ||
this._state.brightness = brightness; | ||
this._state.brightness = brightness.value; | ||
console.log('state', this._state); | ||
@@ -47,3 +47,3 @@ } | ||
this.fixture = { | ||
_configuration: { | ||
configuration: { | ||
displayOccupancy: true, | ||
@@ -50,0 +50,0 @@ displayPower: true, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
158976
3177