Making Smart Homes Smarter with Javascript
@joel__lord
#ConFoo
About me
- Javascript Junkie
- Tinkerer
- Technology enthusiast
@joel__lord
#ConFoo
@joel__lord
#ConFoo
About me
I <3 gadgets
@joel__lord
#ConFoo
The IoT World
- One app per device
- Warning: Your device will look messy
@joel__lord
#ConFoo
Wink Ecosystem
- Connect various devices from various providers within a single application
- They have a REST API
@joel__lord
#ConFoo
Wink Demo
@joel__lord
#ConFoo
Let's make this smarter
- Robots are Wink's macros
@joel__lord
#ConFoo
More smarts
- Making the ecosystem smarter
- Integrating with external applications
@joel__lord
#ConFoo
Introducing IFTTT
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
IFTTT Demo
<Insert funny gif invoking demo gods here>
@joel__lord
#ConFoo
More smarter !
- Let's make it smarter
- We need more control over connected things
@joel__lord
#ConFoo
More smarter !
- Need variables
- Need functions
- Need more integrations
@joel__lord
#ConFoo
Introducing WinkJS
- REST API
- Uses OAUTH
- More or less standard API objects
@joel__lord
#ConFoo
Introducing WinkJS
Door Lock object
{
last_reading: {
locked: true
},
desired_state: {
}
}
@joel__lord
#ConFoo
Introducing WinkJS
Thermostat Object
{
last_reading: {
temperature: "18.5",
units: "C"
},
desired_state: {
}
}
@joel__lord
#ConFoo
Introducing WinkJS
Lightbulb Object
{
last_reading: {
brightness: 0.5,
powered: true
},
desired_state: {
}
}
@joel__lord
#ConFoo
WinkJS Demos
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
WinkJS Demos
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
Thank You !
Questions?
Follow me on Twitter for the slides
Making Smart Homes Smarter with Javascript
By Joel Lord
Making Smart Homes Smarter with Javascript
- 1,631