Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var API = require('node-samsung-airconditioner');
- var express = require('express');
- var app = express();
- var connecting_to = {};
- var known_tokens = {};
- new API().on('discover', function(aircon) {
- if (connecting_to[aircon.options.ip]) {
- return;
- }
- known_tokens[aircon.options.ip] = '33965903-4482-M849-N716-373832354144';
- connecting_to[aircon.options.ip] = true;
- aircon.login(known_tokens[aircon.options.ip], function() {
- app.get('/on', function (req, res) {
- aircon.onoff(true);
- res.send('Hello World!');
- });
- app.get('/off', function (req, res) {
- aircon.onoff(false);
- res.send('Hello World!');
- });
- app.listen(3000, function () {
- console.log('Example app listening on port 3000!');
- });
- // setTimeout(function() { aircon.onoff(true); },1000);
- // setTimeout(function() { aircon.onoff(false); }, 5*60 * 1000);
- }).on('stateChange', function(state) {
- console.log("State changed");
- console.log(state);
- }).on('loginSuccess', function () {
- console.log("HIDSFDs");
- aircon.status();
- });
- }).on('error', function(err) {
- console.log('discovery error: ' + err.message);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement