Last active
September 12, 2020 08:01
-
-
Save toygame/5f4390a994954f7aa7fd168eef69094d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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