Skip to content

Instantly share code, notes, and snippets.

@toygame
Last active September 12, 2020 08:01
Show Gist options
  • Save toygame/5f4390a994954f7aa7fd168eef69094d to your computer and use it in GitHub Desktop.
Save toygame/5f4390a994954f7aa7fd168eef69094d to your computer and use it in GitHub Desktop.
const main = (app, client) => {
/* GET home page. */
app.get('/', function (req, res) {
res.render('index', {
title: 'nodejs-tasmota'
});
});
app.get('/control/on', function (req, res) {
const fullTopic = `tasmota/cmnd/tasmota-1/POWER`
client.publish(fullTopic, "ON");
res.send('Turn on!')
})
app.get('/control/off', function (req, res) {
const fullTopic = `tasmota/cmnd/tasmota-1/POWER`
client.publish(fullTopic, "OFF");
res.send('Turn off!')
})
}
module.exports = main;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment