Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 39 lines (32 sloc) 0.912 kB
16983e5 Added a completely new x10-controller.
root authored
1 #!/usr/bin/env ruby
2 #
3 # The ON cgi page
4
5 #puts ENV['REQUEST_URI']
6 require 'xmlrpc/client'
7
8
9 print "Content-Type: text/html\r\n"
10 print "\r\n"
11
12 url="http://mythtv.stahnkage.com:8080"
13 #ENV['REQUEST_URI'] = '/x10/A1/on.rb'
14 action, address = ""
15 if ENV['REQUEST_URI']
16 address = ENV['REQUEST_URI'].to_s.split('/')[2]
17 action = ENV['REQUEST_URI'].to_s.split('/')[3]
18 else
19 raise "Cannot continue. No requested URI found."
20 end
21
22 if action =~ /on/i
23 action = 'on'.to_s
24 elsif action =~ /off/i
25 action = 'off'.to_s
26 end
27
28 puts '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> '
29 puts "<html>"
30 puts '<head>'
31 puts "<title>Light #{address} #{action}</title>"
32 puts '<link rel="apple-touch-icon" href="/x10/' + action + '.png" />'
33 puts '</head>'
34 puts XMLRPC::Client.new2(url).call("x10.remote." + action, address )
35 puts "<body>"
36 puts "<img src='/x10/#{action}.png' alt='Lights #{action} '>"
37 puts "</body>"
38 puts "</html>"
Something went wrong with that request. Please try again.