7.5 Testing Out the Web Client
With the X10 computer interface working and plugged into the serial port of the computer, fire up a development server of the Rails 3 code via this:
> cd
~/projects/ruby/rails/homprojects/x10switch |
|
>
rails s |
|
|
|
=>
Booting WEBrick |
|
=>
Rails 3.0.5 application starting in development on
http://0.0.0.0:3000 |
|
=>
Call with -d to detach |
|
=>
Ctrl-C to shutdown server |
|
[2011-03-18 16:49:31] INFO WEBrick
1.3.1 |
|
[2011-03-18 16:49:31] INFO ruby 1.8.7
(2009-06-12) [universal-darwin10.0] |
|
[2011-03-18 16:49:31] INFO
WEBrick::HTTPServer#start: pid=10313 port=3000 |
Open a web browser on the local machine and enter the following:
http://localhost:3000/command/on
If everything is coded correctly, you should see
The light should now be on.
in the
browser window, as shown in Figure 25, The browser should
indicate the proper status of the light.

Figure 25. The browser should indicate the proper status of the light.
More importantly, Heyu should have executed the
on
command for the X10 device coded with
the H3
house code. In other
words, the light should have turned on. Turn the light off by
submitting the off
command:
http://localhost:3000/command/off
If the light turned off, congratulations! You have
wired up and programmed everything correctly. When you’re ready to
expand the Rails application to handle even more commands, just add
more if @result ==
statements to the
CommandController
class containing
the command you want Heyu to transmit. These commands could range
from dimming lights to 30 percent, turning an appliance on for a
specified duration, or managing a combination of power on/off
events.
If you’re interested in learning more about programming web applications using the Ruby on Rails framework, check out Programming Ruby: The Pragmatic Programmer’s Guide [TFH09].
Now that the web application server is working, it’s time to build a mobile client.