@joel__lord
#ConFoo
@joel__lord
#ConFoo
@joel__lord
#ConFoo
I <3 gadgets
@joel__lord
#ConFoo
@joel__lord
#ConFoo
@joel__lord
#ConFoo
@joel__lord
#ConFoo
@joel__lord
#ConFoo
@joel__lord
#ConFoo
IFTTT is a free web-based service that allows users to create chains of simple conditional statements, called "recipes", which are triggered based on changes to other web services such as Gmail, Facebook, Instagram, and Pinterest. IFTTT is an abbreviation of "If This Then That"
-Wikipedia
@joel__lord
#ConFoo
<Insert funny gif invoking demo gods here>
@joel__lord
#ConFoo
@joel__lord
#ConFoo
@joel__lord
#ConFoo
@joel__lord
#ConFoo
Door Lock object
{
last_reading: {
locked: true
},
desired_state: {
}
}
@joel__lord
#ConFoo
Thermostat Object
{
last_reading: {
temperature: "18.5",
units: "C"
},
desired_state: {
}
}
@joel__lord
#ConFoo
Lightbulb Object
{
last_reading: {
brightness: 0.5,
powered: true
},
desired_state: {
}
}
@joel__lord
#ConFoo
A simple example
var Wink = require("wink");
var apiCredentials = require("./credentials");
var wink = new Wink(apiCredentials);
wink.on("ready", function() {
var light = wink.getDeviceByName("WinkPresentationLight1");
light.off();
});
@joel__lord
#ConFoo
Yet another Twitter integration
//Web server
var express = require("express");
var app = express();
var server = require("http").createServer(app);
var twit = require("twit");
var keyword = "#confoo";
var Wink = require("../lib");
var apiCredentials = require("./credentials");
var twitterCredentials = require("./twitterCredentials");
var wink = new Wink(apiCredentials);
//Web socket
var port = 3333;
//Start server
server.listen(port, function () {
console.log("Server started on port " + port);
});
//Twitter Stream listener
var t = new twit(twitterCredentials);
var stream = t.stream("statuses/filter", {track: keyword});
var lights = [];
var winkReady = false;
wink.on("ready", function(devices) {
console.log("ready");
winkReady = true;
lights.push(wink.getDeviceByName("WinkPresentationLight1"));
lights.push(wink.getDeviceByName("WinkPresentationLight2"));
});
stream.on("tweet", function (tweet) {
console.log("Got tweet");
if (winkReady) {
var lightIndex = Math.round(Math.random());
console.log("Toggling light #" + lightIndex);
lights[lightIndex].toggle();
}
});
@joel__lord
#ConFoo
Questions?
Follow me on Twitter for the slides