Skip to content

Instantly share code, notes, and snippets.

@brandonburke
Created February 13, 2015 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonburke/4180fc10813f5ffc0983 to your computer and use it in GitHub Desktop.
Save brandonburke/4180fc10813f5ffc0983 to your computer and use it in GitHub Desktop.
require 'sinatra'
require 'wemo'
set :port, 9494
set :bind, '192.168.2.8'
switches = WeMo.light_switches
foyer = switches.find {|s| s.name == "Foyer Light" }
porch = switches.find {|s| s.name == "Porch Light" }
get '/foyer/on' do
foyer.on
end
get '/foyer/off' do
foyer.off
end
get '/foyer/toggle' do
foyer.status == true ? foyer.off : foyer.on
end
get '/porch/on' do
porch.on
end
get '/porch/off' do
porch.off
end
get '/porch/toggle' do
porch.status == true ? porch.off : porch.on
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment