Skip to content

Instantly share code, notes, and snippets.

@gr2m
Last active August 29, 2016 09:01
Show Gist options
  • Save gr2m/5465679 to your computer and use it in GitHub Desktop.
Save gr2m/5465679 to your computer and use it in GitHub Desktop.
Imagine you could control other devices with a simple JavaScript API, right from your browser.
// Ask the coffee machine at IP 192.168.2.2 to do its job
device('192.168.2.2')
.do( 'coffee' )
.then( wakeMeUpCallback )
// turn all lights on
device.findAll('light').do('turnOn')
@jpillora
Copy link

Checkout http://ninjablocks.com/ it's running Node and exposes webhooks to it's connected devices. Right now, you could definitely make it turn on your coffee machine, though it's probably going to need some arduino smarts to notify you when it's done. Just set your alarm for 5mins after the coffee is scheduled :P

For example, here's the temperature data (in Celsius) for my house recently:

{
  "result": 1,
  "error": null,
  "id": 0,
  "data": [{
    "t": "2013-05-06T12:00:00.000Z",
    "v": 22.077272727272728
  }, {
    "t": "2013-05-06T13:00:00.000Z",
    "v": 21.83124999999998
  }, {
    "t": "2013-05-06T14:00:00.000Z",
    "v": 21.767647058823524
  }, {
    "t": "2013-05-06T15:00:00.000Z",
    "v": 21.656521739130405
  }, {
    "t": "2013-05-06T16:00:00.000Z",
    "v": 21.374193548387094
  }, {
    "t": "2013-05-06T17:00:00.000Z",
    "v": 20.998823529411773
  }, {
    "t": "2013-05-06T18:00:00.000Z",
    "v": 20.626666666666683
  }, {
    "t": "2013-05-06T19:00:00.000Z",
    "v": 20.431168831168836
  }, {
    "t": "2013-05-06T20:00:00.000Z",
    "v": 20.22666666666667
...

@EvanHahn
Copy link

Typo police: "to do it's job" should be "to do its job".

@gr2m
Copy link
Author

gr2m commented May 15, 2013

@EvanHahn fixed, cheers!

@jpillora

this is awesome! I want an API for all the things in my house! Let's make some dream code for that, would make a cool example

@brandondrew
Copy link

More typo police: "it's connected devices" should be "its connected devices".

"it's connected devices" == "it is connected devices"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment