var Insteon = require('home-controller').Insteon;
var hub = new Insteon();
var route = require('koa-route');
var koa = require('koa');
var app = koa();

app.use(function *(next){
  try {
    yield next;
  } catch (err) {
    console.log('Error:', err.message);
    this.status = err.status || 500;
    this.body = err.message;
  }
});

app.use(route.get('/light/:id/on', turnOn));
app.use(route.get('/light/:id/off', turnOff));


function *turnOn(id) {
  var status = yield hub.light(id).turnOn();
  if(status.response) {
    this.body = 'on';
  }
}

function *turnOff(id) {
  var status = yield hub.light(id).turnOff();
  if(status.response) {
    this.body='off';
  }
}

hub.connect(process.env.HUB_IP, function () {
  app.listen(3000);
});

@@ -422,16 +422,121 @@
 Off));%0A%0A
+app.use(route.get('/thermostat/:id/up', tempUp));%0Aapp.use(route.get('/thermostat/:id/down', tempDown));%0A%0A
 %0Afunctio
@@ -771,16 +771,342 @@
 %0A  %7D%0A%7D%0A%0A
+function *tempUp(id) %7B%0A  var therm = hub.thermostat(id);%0A  var status = yield therm.tempUp();%0A  if(status.response) %7B%0A    this.body = yield therm.temp();%0A  %7D%0A%7D%0A%0Afunction *tempDown(id) %7B%0A  var therm = hub.thermostat(id);%0A  var status = yield therm.tempDown();%0A  if(status.response) %7B%0A    this.body = yield therm.temp();%0A  %7D%0A%7D%0A%0A
 hub.conn

Add thermostat control to REST example