Add changecolorintent

This commit is contained in:
Alex Ellis
2016-12-30 19:24:25 +00:00
parent 8734a3a5ac
commit 4573f14f65
10 changed files with 129 additions and 5 deletions

View File

@ -0,0 +1,40 @@
"use strict"
var mqtt = require('mqtt');
class Send {
constructor(topic) {
this.topic = topic;
}
sendIntensity(req, done) {
var ops = { port: 1883, host: "iot.eclipse.org" };
var client = mqtt.connect(ops);
client.on('connect', () => {
console.log("Connected");
let payload = req;
let cb = () => {
done();
};
client.publish(this.topic, JSON.stringify(payload), {qos: 1}, cb);
});
}
sendColor(req, done) {
var ops = { port: 1883, host: "iot.eclipse.org" };
var client = mqtt.connect(ops);
let cb = () => {
done();
};
client.on('connect', () => {
console.log("Connected");
let payload = req;
client.publish(this.topic, JSON.stringify(payload), {qos: 1}, cb);
});
}
}
module.exports = Send;