SODashServer/routes/heating_v1.js

53 lines
921 B
JavaScript
Raw Normal View History

2016-05-13 12:44:57 +00:00
'use strict';
2016-04-13 09:01:28 +00:00
/**
* Created by Martin on 09/02/2016.
*/
var log4js = require('log4js');
var logger = log4js.getLogger();
var mqttConnect;
function doHeatingOn() {
2016-05-13 12:44:57 +00:00
mqttConnect.doConnection().heatingOn();
2016-04-13 09:01:28 +00:00
}
function doHeatingOff() {
2016-05-13 12:44:57 +00:00
mqttConnect.doConnection().heatingOff();
2016-04-13 09:01:28 +00:00
}
function setUseRef(ref) {
2016-05-13 12:44:57 +00:00
mqttConnect = ref;
2016-04-13 09:01:28 +00:00
}
function getStatus() {
2016-05-13 12:44:57 +00:00
logger.debug(mqttConnect.socketSet.getClientStatus());
2016-04-13 09:01:28 +00:00
}
module.exports = {
2016-05-13 12:44:57 +00:00
mqttConnect: null,
socket: null,
use: function(ref) {
2016-04-13 09:01:28 +00:00
setUseRef(ref);
2016-05-13 12:44:57 +00:00
},
turnoff: function(req, res) {
2016-04-13 09:01:28 +00:00
doHeatingOff();
2016-05-13 12:44:57 +00:00
res.json({});
},
turnon: function(req, res) {
2016-04-13 09:01:28 +00:00
doHeatingOn();
2016-05-13 12:44:57 +00:00
res.json({});
},
setsocket: function(socket) {
2016-04-13 09:01:28 +00:00
this.socket = socket;
return this;
2016-05-13 12:44:57 +00:00
},
subscribe: function(socket) {
this.socket.subscribe('Heating','HeatingDataReceived');
2016-05-13 12:44:57 +00:00
}
};
2016-04-13 09:01:28 +00:00