Skip to content

Commit 9a65a1e

Browse files
committed
code quality changes
1 parent b433b42 commit 9a65a1e

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

homemon-server/homemon-server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ mqttclient.on("connect", function() {
108108
mqttclient.subscribe("$SYS/#");
109109
mqttclient.on("message", function(topic, message) {
110110
var value = Number(message);
111-
messageString = value.toString();
111+
var messageString = value.toString();
112112
// console.log (topic + " " + message.toString());
113113

114114
if (topic == "push/alert") {

homemon-stats/homemon-stats.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
// service settings file
22
console.log("process.env.NODE_ENV:" + process.env.NODE_ENV);
33
switch (process.env.NODE_ENV) {
4-
case 'development':
4+
case "development":
55
console.log ("development mode");
6-
var config = require('../config.json');
6+
var config = require("../config.json");
77
break;
8-
case 'production':
8+
case "production":
99
default:
1010
console.log ("production mode");
11-
var config = require('../config.json');
11+
var config = require("../config.json");
1212
}
1313

1414

1515

16-
var redis = require('redis')
16+
var redis = require("redis")
1717
,redisClient = redis.createClient(parseInt(config.redis.port,10), config.redis.host);
1818

1919

@@ -31,9 +31,9 @@ var recordsLastValue = {};
3131

3232
// get last stored values from Redis
3333
// needs to be blocking to get everything initialised nicely when starting
34-
var execSync = require('sync-exec');
34+
var execSync = require("sync-exec");
3535

36-
var result = execSync('redis-cli -h ' + config.redis.host + ' get recordsHourly');
36+
var result = execSync("redis-cli -h " + config.redis.host + " get recordsHourly");
3737
console.log("Loading hourly records from redis...");
3838
try {
3939
recordsHourly = JSON.parse(result.stdout);
@@ -42,7 +42,7 @@ try {
4242
console.log ("no records loaded");
4343
}
4444

45-
result = execSync('redis-cli -h ' + config.redis.host + ' get recordsDaily');
45+
result = execSync("redis-cli -h " + config.redis.host + " get recordsDaily");
4646
console.log("Loading daily records from redis...");
4747
try {
4848
recordsDaily = JSON.parse(result.stdout);
@@ -54,18 +54,18 @@ try {
5454

5555

5656
// connect to to MQTT
57-
var mqtt = require('mqtt');
57+
var mqtt = require("mqtt");
5858
var mqttclient = mqtt.connect(config.mqtt.host, config.mqtt.options);
5959

60-
mqttclient.on('connect', function() {
61-
mqttclient.subscribe('sensors/power/+');
62-
console.log('subscribing to sensors/power/+ on ' + config.mqtt.host);
63-
mqttclient.subscribe('sensors/snmp/+/+');
64-
console.log('subscribing to sensors/snmp/+/+ on ' + config.mqtt.host);
65-
mqttclient.subscribe('sensors/temperature/+');
66-
console.log('subscribing to sensors/temperature/+ on ' + config.mqtt.host);
60+
mqttclient.on("connect", function() {
61+
mqttclient.subscribe("sensors/power/+");
62+
console.log("subscribing to sensors/power/+ on " + config.mqtt.host);
63+
mqttclient.subscribe("sensors/snmp/+/+");
64+
console.log("subscribing to sensors/snmp/+/+ on " + config.mqtt.host);
65+
mqttclient.subscribe("sensors/temperature/+");
66+
console.log("subscribing to sensors/temperature/+ on " + config.mqtt.host);
6767

68-
mqttclient.on('message', function(topic, message) {
68+
mqttclient.on("message", function(topic, message) {
6969
var currenttime = new Date();
7070

7171
// have we seen this mesage before?
@@ -187,14 +187,14 @@ mqttclient.on('connect', function() {
187187

188188

189189

190-
var mqtt2 = require('mqtt');
190+
var mqtt2 = require("mqtt");
191191
var mqttclient2 = mqtt2.connect(config.mqtt.host, config.mqtt.options);
192192

193-
mqttclient2.on('connect', function() {
194-
mqttclient2.subscribe('sensors/#');
195-
console.log('subscribing to sensors/# on ' + config.mqtt.host);
193+
mqttclient2.on("connect", function() {
194+
mqttclient2.subscribe("sensors/#");
195+
console.log("subscribing to sensors/# on " + config.mqtt.host);
196196

197-
mqttclient2.on('message', function(topic, message) {
197+
mqttclient2.on("message", function(topic, message) {
198198
var time = new Date();
199199
var jsonMessage = {
200200
topic: topic,
@@ -205,7 +205,7 @@ mqttclient2.on('connect', function() {
205205
mqttclient2.publish("jsonsensors", JSON.stringify(jsonMessage));
206206

207207
// MongoClient.connect (config.mongo.host, function (err, db) {
208-
// db.collection ('homedata').insertOne (jsonMessage);
208+
// db.collection ("homedata").insertOne (jsonMessage);
209209
// db.close ();
210210
// });
211211
});
@@ -224,4 +224,4 @@ savestate = function() {
224224
// frequently store cumulative date to preserve it across restarts, etc.
225225
var savePeriod = 65; // in seconds
226226
setInterval (savestate, savePeriod * 1000);
227-
process.on('SIGUSR1', savestate); // and save on signal
227+
process.on("SIGUSR1", savestate); // and save on signal

0 commit comments

Comments
 (0)