Fix whitespace

This commit is contained in:
Sebastian Maier 2020-10-13 04:08:26 +02:00
parent 0155a5557e
commit 988d2ada35
2 changed files with 103 additions and 104 deletions

View File

@ -5,16 +5,15 @@ var colorOn = "\x1b[30;47m";
var colorOff = "\x1b[0m"; var colorOff = "\x1b[0m";
function SmartHomeNGConnection(platform, log, host, port) { function SmartHomeNGConnection(platform, log, host, port) {
this.log = log; this.log = log;
this.platform = platform; this.platform = platform;
this.connected = false; this.connected = false;
this.updateCallback = undefined; this.updateCallback = undefined;
this.tomonitor = []; this.tomonitor = [];
this.retryTimer = 10; this.retryTimer = 10;
this.shng_host = host;
this.shng_port = port;
this.shng_host = host;
this.shng_port = port;
} }
SmartHomeNGConnection.prototype.init = function () { SmartHomeNGConnection.prototype.init = function () {
@ -55,7 +54,7 @@ SmartHomeNGConnection.prototype.connect = function(host, ip) {
} }
SmartHomeNGConnection.prototype.receive = function(message) { SmartHomeNGConnection.prototype.receive = function(message) {
var msg = JSON.parse(message.utf8Data); var msg = JSON.parse(message.utf8Data);
//this.log(msg); //this.log(msg);
if (msg.items) { if (msg.items) {
for (int = 0; int < msg.items.length; int++) { for (int = 0; int < msg.items.length; int++) {
@ -105,6 +104,6 @@ SmartHomeNGConnection.prototype.startMonitoring = function() {
} }
module.exports = { module.exports = {
SmartHomeNGConnection: SmartHomeNGConnection SmartHomeNGConnection: SmartHomeNGConnection
} }

View File

@ -267,7 +267,7 @@ SmartHomeNGAccessory.prototype = {
monitoring.push({name: name, characteristic: characteristic.displayName, item: shngitem, callback: callback, inverted: inverted}); monitoring.push({name: name, characteristic: characteristic.displayName, item: shngitem, callback: callback, inverted: inverted});
}, },
/** get methods /** get methods
* *
*/ */
getState: function(callback, shngitem, inverted) { getState: function(callback, shngitem, inverted) {
@ -315,7 +315,7 @@ SmartHomeNGAccessory.prototype = {
var numericValue = 0; var numericValue = 0;
value = ( value>=0 ? (value<=100 ? value:100):0 ); //ensure range 0..100 value = ( value>=0 ? (value<=100 ? value:100):0 ); //ensure range 0..100
if (inverted) { if (inverted) {
numericValue = 100 - value; numericValue = 100 - value;
} else { } else {
numericValue = value; numericValue = value;
} }
@ -334,7 +334,7 @@ SmartHomeNGAccessory.prototype = {
var numericValue = 0; var numericValue = 0;
value = ( value>=0 ? (value<=360 ? value:360):0 ); //ensure range 0..360 value = ( value>=0 ? (value<=360 ? value:360):0 ); //ensure range 0..360
if (inverted) { if (inverted) {
numericValue = 360 - value; numericValue = 360 - value;
} else { } else {
numericValue = value; numericValue = value;
} }
@ -348,35 +348,35 @@ SmartHomeNGAccessory.prototype = {
}, },
setInt: function(value, callback, context, shngitem) { setInt: function(value, callback, context, shngitem) {
if (context === 'fromSHNG') { if (context === 'fromSHNG') {
if (callback) { if (callback) {
callback(); callback();
} }
} else { } else {
var numericValue = 0; var numericValue = 0;
if (value && value>=0) { if (value && value>=0) {
numericValue = value; numericValue = value;
} }
this.log("["+ this.name +"] Setting " + shngitem + " int to %s", numericValue); this.log("["+ this.name +"] Setting " + shngitem + " int to %s", numericValue);
this.shngcon.setValue(shngitem, numericValue); this.shngcon.setValue(shngitem, numericValue);
if (callback) callback(); if (callback) callback();
} }
}, },
setFloat: function(value, callback, context, shngitem) { setFloat: function(value, callback, context, shngitem) {
if (context === 'fromSHNG') { if (context === 'fromSHNG') {
if (callback) { if (callback) {
callback(); callback();
} }
} else { } else {
var numericValue = 0; var numericValue = 0;
if (value && value>=0) { if (value && value>=0) {
numericValue = value; numericValue = value;
} }
this.log("["+ this.name +"] Setting " + shngitem + " float to %s", numericValue); this.log("["+ this.name +"] Setting " + shngitem + " float to %s", numericValue);
this.shngcon.setValue(shngitem, numericValue); this.shngcon.setValue(shngitem, numericValue);
if (callback) callback(); if (callback) callback();
} }
}, },
/** bindCharacteristic /** bindCharacteristic
@ -471,10 +471,10 @@ SmartHomeNGAccessory.prototype = {
// Target temperature // Target temperature
if (config.targettemperature) { if (config.targettemperature) {
this.log("["+ this.name +"] TemperatureSensor TargetTemperature characteristic enabled"); this.log("["+ this.name +"] TemperatureSensor TargetTemperature characteristic enabled");
myService.getCharacteristic(Characteristic.TargetTemperature).setProps({ myService.getCharacteristic(Characteristic.TargetTemperature).setProps({
minValue: config.targettemperatureminimum || 0, minValue: config.targettemperatureminimum || 0,
maxValue: config.targettemperaturemaximum || 40 maxValue: config.targettemperaturemaximum || 40
}); });
this.bindCharacteristic(myService, Characteristic.TargetTemperature, "Float", config.targettemperature, false); this.bindCharacteristic(myService, Characteristic.TargetTemperature, "Float", config.targettemperature, false);
} }
/* /*