SODashServer/routes/heating_v1.js
Martin Donnelly d93ebb4466 init
2016-04-13 10:01:28 +01:00

60 lines
1.1 KiB
JavaScript

"use strict";
/**
* Created by Martin on 09/02/2016.
*/
var log4js = require('log4js');
var logger = log4js.getLogger();
var mqttConnect;
function doHeatingOn() {
mqttConnect.doConnection().heatingOn();
}
function doHeatingOff() {
mqttConnect.doConnection().heatingOff();
}
function setUseRef(ref) {
mqttConnect = ref;
}
function getStatus() {
logger.debug(mqttConnect.socketSet.getClientStatus());
}
module.exports = {
mqttConnect:null,
socket:null,
use: function (ref) {
setUseRef(ref);
},
turnoff: function (req, res) {
doHeatingOff();
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify({}));
},
turnon: function (req, res) {
doHeatingOn();
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify({}));
},
setsocket: function (socket) {
this.socket = socket;
return this;
},
subscribe: function (socket) {
this.socket.subscribe('HeatingISP15','HeatingDataReceived');
}
};