making smart homes smarter with javascript

63
Smart Homes Made Smarter With JS Joel Lord Guidebook app: NEPHP2016

Upload: joel-lord

Post on 16-Feb-2017

117 views

Category:

Engineering


4 download

TRANSCRIPT

Page 1: Making Smart Homes Smarter With Javascript

Smart Homes Made Smarter

With JSJoel LordGuidebook app:

NEPHP2016

Page 2: Making Smart Homes Smarter With Javascript

www.spiria.com

Smart Homes Made Smarter With Javascript

Presented ByJOEL LORD

North East PHP 2016, Charlottetown, PE

August 5th, 2016

Page 3: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

JOEL LORDAbout me, eh?

• Javascript Junkie• Tinkerer• Technology enthusiast

Page 4: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Page 5: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

JOEL LORDAbout me, eh?

• Javascript Junkie• Tinkerer• Technology enthusiast

Page 6: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

AGENDA Wink EcosystemMacros (or Robots)IFTTTIntroducing WinkJSDemosQ&A

Page 7: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

I <3 GADGETSAbout me, eh?

Page 8: Making Smart Homes Smarter With Javascript

State of the MarketHOME AUTOMATION

Page 9: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

The Home automation market

• There are many options out there !

@joel__lord

Page 10: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

The Home automation market

• There are many options out there !• Nest

@joel__lord

Page 11: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

The Home automation market

• There are many options out there !• Nest• GE

@joel__lord

Page 12: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

The Home automation market

• There are many options out there !• Nest• GE• Philips

@joel__lord

Page 13: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

The Home automation market

• There are many options out there !• Nest• GE• Philips• Insteon

@joel__lord

Page 14: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

The Home automation market

• There are many options out there !• Nest• GE• Philips• Insteon• Samsung SmartThings

@joel__lord

Page 15: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

The Home automation market

• There are many options out there !• Nest• GE• Philips• Insteon• Samsung SmartThings• Belkin Wemo

@joel__lord

Page 16: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

The Home automation market

• There are many options out there !• Nest• GE• Philips• Insteon• Samsung SmartThings• Belkin Wemo• iRobot

@joel__lord

Page 17: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

The Home automation market

• There are many options out there !• Nest• GE• Philips• Insteon• Samsung SmartThings• Belkin Wemo• iRobot• Schlage

@joel__lord

Page 18: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

The Home automation market

• There are many options out there !• Nest• GE• Philips• Insteon• Samsung SmartThings• Belkin Wemo• iRobot• Schlage• Lutron

@joel__lord

Page 19: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

The Home automation market

• There are many options out there !• Nest• GE• Philips• Insteon• Samsung SmartThings• Belkin Wemo• iRobot• Schlage• Lutron• Zigbee

@joel__lord

Page 20: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

The Home automation market

• There are many options out there !• Nest• GE• Philips• Insteon• Samsung SmartThings• Belkin Wemo• iRobot• Schlage• Lutron• Zigbee• Z-wave

@joel__lord

Page 21: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

The Home automation market

• There are many options out there !• Nest• GE• Philips• Insteon• Samsung SmartThings• Belkin Wemo• iRobot• Schlage• Lutron• Zigbee• Z-wave• X10

@joel__lord

Page 22: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

The Home automation market

• There are many options out there !• Nest• GE• Philips• Insteon• Samsung SmartThings• Belking Wemo• iRobot• Schlage• Lutron• Zigbee• Z-wave• X10

@joel__lord

Page 23: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

The home automation market

• Each device has it’s own app• Soon, your phone is a mess and you can’t control your

devices

@joel__lord

Page 24: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink ecosystem

• Connect various devices from various providers within a single application

• 05/01/2023

• 24

@joel__lord

Page 25: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink ecosystem

• Connect various devices from various providers within a single application

• But even better…

• 05/01/2023

• 25

@joel__lord

Page 26: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink ecosystem

• Connect various devices from various providers within a single application

• But even better… They have an API

• 05/01/2023

• 26

@joel__lord

Page 27: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink ecosystem

• Connect various devices from various providers within a single application

• But even better… They have an API• It’s not what you do with it that counts, it’s what you can

do

• 05/01/2023

• 27

@joel__lord

Page 28: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink ecosystem

• 05/01/2023

@joel__lord

• 28

Page 29: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink ecosystem

• 05/01/2023

@joel__lord

• 29

Page 30: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink ecosystem

• 05/01/2023

@joel__lord

• 30

Page 31: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink demo

• 05/01/2023

• 31

@joel__lord

Page 32: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink demo

• 05/01/2023

@joel__lord

• 32

• Pretty limited

Page 33: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink demo

• 05/01/2023

@joel__lord

• 33

• Pretty limited• Robots are the Wink equivalent to macros

Page 34: Making Smart Homes Smarter With Javascript

Wink RobotsMAKE IT SMARTER

Page 35: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink demo

• 05/01/2023

@joel__lord

• 35

Page 36: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink demo

• 05/01/2023

@joel__lord

• 36

Page 37: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink demo

• 05/01/2023

@joel__lord

• 37

Page 38: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink demo

• 05/01/2023

@joel__lord

• 38

Page 39: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink demo

• 05/01/2023

@joel__lord

• 39

Page 40: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink demo

• 05/01/2023

@joel__lord

• 40

Page 41: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Wink demo

• 05/01/2023

@joel__lord

• 41

Page 42: Making Smart Homes Smarter With Javascript

IFTTT IntegrationMAKE IT SMARTER

Page 43: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Let’s make it smarter

• 05/01/2023

@joel__lord

• 43

• Integration with Amazon Echo• Integration with IFTTT

– Either using the Maker Channel– Or using a third party

Page 44: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Introducing IFTTT

• 05/01/2023

@joel__lord

• 44

• 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

Page 45: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

IFTTT demo

• 05/01/2023

@joel__lord

• 45

• http://cl.ly/300R1310191F

Page 46: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

And even more smart !

• 05/01/2023

@joel__lord

• 46

• Let’s make it even smarter• We need more control over our things

Page 47: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

And even more smart !

• 05/01/2023

@joel__lord

• 47

• We need :– Variables– Functions– More third party integrations

Page 48: Making Smart Homes Smarter With Javascript

Introducing WinkJsMAKE IT SMARTER

Page 49: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Introducing Winkjs

• 05/01/2023

@joel__lord

• 49

• REST API• Uses OAUTH• More or less standard API objects

Page 50: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Introducing winkjs

• 05/01/2023

@joel__lord

• 50

• Door Lock object

{ last_reading: { locked: true }, desired_state: { }}

Page 51: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Introducing winkjs

• 05/01/2023

@joel__lord

• 51

• Thermostat object

{ last_reading: { temperature: "18.5", units: "C" }, desired_state: { }}

Page 52: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Introducing winkjs

• 05/01/2023

@joel__lord

• 52

• Light Bulb object

{ last_reading: { brightness: 0.5, powered: true }, desired_state: { }}

Page 53: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Introducing winkjs

• 05/01/2023

@joel__lord

• 53

Page 54: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Introducing winkjs

• 05/01/2023

@joel__lord

• 54

Page 55: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Introducing winkjs

• 05/01/2023

@joel__lord

• 55

• A simple Hello World

var Wink = require("wink"); var apiCredentials = require("./credentials");

var wink = new Wink(apiCredentials);

wink.on("ready", function() { var light = wink.getDeviceByName("Light1"); light.off(); });

Page 56: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

Introducing winkjs

• 05/01/2023

@joel__lord

• 56

• A Twitter integration

//Web server var express = require("express"); var app = express(); var server = require("http").createServer(app); var twit = require("twit"); var keyword = "#devteach"; 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(); } });

Page 57: Making Smart Homes Smarter With Javascript

IT’S CODING TIME!LET’S GET SERIOUS

Page 58: Making Smart Homes Smarter With Javascript

IT’S CODING TIME!LET’S GET SERIOUS

Page 59: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

How about Security?

• 05/01/2023

@joel__lord

• 59

• You have to be intentional

Page 60: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

How about Security?

• 05/01/2023

@joel__lord

• 60

• You have to be intentional• Keep in mind that you are exposing your home lights to

hackers

Page 61: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

How about Security?

• 05/01/2023

@joel__lord

• 61

• You have to be intentional• Keep in mind that you are exposing your home lights to

hackers• Or worse… your front door lock.

Page 62: Making Smart Homes Smarter With Javascript

#NEPHP@joel__lord

How about Security?

• 05/01/2023

@joel__lord

• 62

• Killing a Jeep on the highway: https://www.wired.com/2015/07/hackers-remotely-kill-jeep-highway/

• Hacking smart door bells: http://thehackernews.com/2016/01/doorbell-hacking-wifi-pasword.html

Page 63: Making Smart Homes Smarter With Javascript

DOCUMENT CONFIDENTIEL, TOUT DROIT RÉSERVÉ

PRESENTED BY

The End !

Questions ?

JOEL LORDAugust 2016

TWITTER: @JOEL__LORDGITHUB: HTTP://GITHUB.COM/JOELLORD

http://bit.ly/2au33dH