Created
February 13, 2015 03:02
-
-
Save brandonburke/4180fc10813f5ffc0983 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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