commands to DHT send also over MQTT;
Removes the need to have direct access over TCP/IP
This commit is contained in:
24
dht.js
24
dht.js
@@ -91,7 +91,7 @@ app.post('/accontrol',
|
||||
|
||||
var code = ac.Tlc112.GetCommand();
|
||||
|
||||
mqtt_client.publish('cmnd/', 'controller')
|
||||
//!mqtt_client.publish('cmnd/', 'controller')
|
||||
//break it
|
||||
//code = code.substring(150);
|
||||
//console.log("RAW: " + code);
|
||||
@@ -138,16 +138,22 @@ config.gardenIP = process.env.GARDEN_IP || config.gardenIP
|
||||
app.use('/water',function(req, res){
|
||||
var time = req.query.t;
|
||||
console.log("Watering cmd for: " + time);
|
||||
request('http://'+config.gardenIP+'/tools?cmd=event,manualwatering='+ time, { json: true }, (err, res, body) => {
|
||||
if (err) { return console.log("Problem watering: " + err); }
|
||||
console.log("Watering cmd successfully sent!");
|
||||
});
|
||||
if(config.gardenIP !="" && config.gardenIP !="0.0.0.0"){
|
||||
request('http://'+config.gardenIP+'/tools?cmd=event,manualwatering='+ time, { json: true }, (err, res, body) => {
|
||||
if (err) { return console.log("Problem watering: " + err); }
|
||||
console.log("Watering cmd successfully sent over HTTP!");
|
||||
});
|
||||
}
|
||||
mqtt.Send("event,manualwatering="+ time,"");
|
||||
});
|
||||
app.use('/waterStop',function(req, res){
|
||||
request('http://'+config.gardenIP+'/tools?cmd=event,stopwatering', { json: true }, (err, res, body) => {
|
||||
if (err) { return console.log("Problem watering: " + err); }
|
||||
console.log("STOP watering cmd sent!");
|
||||
});
|
||||
if(config.gardenIP !="" && config.gardenIP !="0.0.0.0"){
|
||||
request('http://'+config.gardenIP+'/tools?cmd=event,stopwatering', { json: true }, (err, res, body) => {
|
||||
if (err) { return console.log("Problem watering: " + err); }
|
||||
console.log("STOP watering cmd sent!");
|
||||
});
|
||||
}
|
||||
mqtt.Send("event,stopwatering","Garden/cmd");
|
||||
});
|
||||
|
||||
function BroadcastWS(msg){
|
||||
|
||||
Reference in New Issue
Block a user