mirror of
https://gitlab.silvrtree.co.uk/martind2000/SODashServer.git
synced 2025-01-11 04:35:10 +00:00
60 lines
1.0 KiB
JavaScript
60 lines
1.0 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('Heating','HeatingDataReceived');
|
|
}
|
|
};
|
|
|
|
|