r-house

                       Fernand Galiana

Friday, May 8, 2009
r-house

                       Fernand Galiana

Friday, May 8, 2009
credits
                         rfuzz
darkfish-rdoc logging
                        rack
      id3lib-ruby rails
beanstalk...
warning

Friday, May 8, 2009
Friday, May 8, 2009
Friday, May 8, 2009
groups.google.com/group/derailed

Friday, May 8, 2009
ZiYa




                      git://github.com/derailed/ziya.git

Friday, May 8, 2009
MOle




                      git://github.com/derailed/mole.git

Friday, May 8, 2009
homeautomation

                        ?
Friday, May 8, 2009
homeautomation

                        ?
Friday, May 8, 2009
telephonydigital   media   climate


  lightingav-equipmentsecurity

Friday, May 8, 2009
Friday, May 8, 2009
Appliance     kWh / Year    Cost
                           Tv           240         $30
                         Fridge  ...
opensource HA

                         openremote
                         control4
                         linuxmce
   ...
protocols


                      X10 - Insteon
                      LonWorks/Batibus
                      ZigBee/Zwave
...
Friday, May 8, 2009
linuxmce
Friday, May 8, 2009
the gear
Friday, May 8, 2009
Asus EEE Box
                      MCV Zwave dongle
                      Panasonic IP Cam
                      Monster C...
> gem install derailed-rhouse
                      git://github.com/derailed/rhouse.git




Friday, May 8, 2009
DCE router



Friday, May 8, 2009
DCE router
                      0 28 1 184 76 quot;50quot;


Friday, May 8, 2009
DCE router
                      0 28 1 184 76 quot;50quot;


Friday, May 8, 2009
DCE router
                      0 28 1 184 76 quot;50quot;


Friday, May 8, 2009
DCE router
                      0 28 1 184 76 quot;50quot;


Friday, May 8, 2009
DCE router
                      0 28 1 184 76 quot;50quot;


Friday, May 8, 2009
DCE router
                      0 28 1 184 76 quot;50quot;


Friday, May 8, 2009
DCE router
                      0 28 1 184 76 quot;50quot;


Friday, May 8, 2009
architecture


                                     devices
                           dce




                           ...
architecture


                                     devices
                           dce




                           ...
architecture


                                     devices
                           dce




                           ...
architecture
                        rh_interceptor



                                         devices
                  ...
architecture
                        rh_interceptor



                                         devices
                  ...
architecture
                           rh_interceptor



             rh_rhouse                      devices
            ...
architecture
                           rh_interceptor



             rh_rhouse                      devices
            ...
architecture
                           rh_interceptor



             rh_rhouse                      devices
            ...
architecture
                        rh_interceptor




Friday, May 8, 2009
architecture
                        rh_interceptor


                       beanstalk queue




Friday, May 8, 2009
architecture
                                 rh_interceptor


                                beanstalk queue

          ...
architecture
                                 rh_interceptor


                                beanstalk queue

          ...
architecture




Friday, May 8, 2009
architecture
                         house_rules




Friday, May 8, 2009
architecture
                         house_rules



                         rh_rhouse




Friday, May 8, 2009
architecture
                         house_rules



                         rh_rhouse




Friday, May 8, 2009
architecture
                         house_rules



                         rh_rhouse




Friday, May 8, 2009
architecture
                         house_rules



                         rh_rhouse




Friday, May 8, 2009
@rhousse

Friday, May 8, 2009
demo

Friday, May 8, 2009
rh-interceptor

            def initialize( opts={} )
              logger.debug quot;Initializing Interceptor in `#{Rhous...
rh-interceptor
                        common: &common
                          port:           3450
                    ...
rh-interceptor
              def connect
                @in_socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
              ...
rh-interceptor

     def register_events
       events = config( :events )
       events.each_pair do |event_id, message_t...
rhouse-app
     module MyRhouse
       class HouseRules < Rhouse::Worker
         # Fetch the yaml configuration file
    ...
house-rules

 module MyRhouse::Rules
   class HouseRuleBook < Ruleby::Rulebook
     def rules
        # Deal with music
  ...
rhouse-ws
      # Initializes Rhouse
      configure do
        Rhouse.initialize(
          :environment => ENV['RH_ENV']...
ws-client
           def send_cmd( command_hash )
             params = command_hash.keys.map{ |k| quot;#{k}=#{command_has...
demo

Friday, May 8, 2009
references

                      linuxmce.org
                      z-wavealliance.org
                      micasaverde....
links

                      liquidrail.com
                      groups.google.com/group/rhouse_gem
                     ...
Thanks!


Friday, May 8, 2009
questions?




Friday, May 8, 2009
Upcoming SlideShare
Loading in...5
×

Rhouse - Home automation is ruby ?

8,002

Published on

Home automation using ruby. Control various devices around your house, using your iphone and yes even twitter...

Published in: Technology, Education
1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total Views
8,002
On Slideshare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
155
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Rhouse - Home automation is ruby ?

  1. 1. r-house Fernand Galiana Friday, May 8, 2009
  2. 2. r-house Fernand Galiana Friday, May 8, 2009
  3. 3. credits rfuzz darkfish-rdoc logging rack id3lib-ruby rails beanstalk-client twibot flexmock rake bones passenger arrayfields main sinatra json twitter4r memcached system-timer ruleby toholio-serialport Friday, May 8, 2009
  4. 4. warning Friday, May 8, 2009
  5. 5. Friday, May 8, 2009
  6. 6. Friday, May 8, 2009
  7. 7. groups.google.com/group/derailed Friday, May 8, 2009
  8. 8. ZiYa git://github.com/derailed/ziya.git Friday, May 8, 2009
  9. 9. MOle git://github.com/derailed/mole.git Friday, May 8, 2009
  10. 10. homeautomation ? Friday, May 8, 2009
  11. 11. homeautomation ? Friday, May 8, 2009
  12. 12. telephonydigital media climate lightingav-equipmentsecurity Friday, May 8, 2009
  13. 13. Friday, May 8, 2009
  14. 14. Appliance kWh / Year Cost Tv 240 $30 Fridge 500 $60 Dw 168 $20 Lamp(60w) 130 $16 MacBook 84 $10 24hrs Washer 26 $6 Dryer 420 $50 Water Heater 2,832 $336 Furnace 2,232 $264 Total 6,632 $785.24 Friday, May 8, 2009
  15. 15. opensource HA openremote control4 linuxmce mrhouse domotiga linuxha Friday, May 8, 2009
  16. 16. protocols X10 - Insteon LonWorks/Batibus ZigBee/Zwave Friday, May 8, 2009
  17. 17. Friday, May 8, 2009
  18. 18. linuxmce Friday, May 8, 2009
  19. 19. the gear Friday, May 8, 2009
  20. 20. Asus EEE Box MCV Zwave dongle Panasonic IP Cam Monster Cable Zwave dimmer HomeSeer Zwave sensor Arduino ( Eventual furniture? ) Friday, May 8, 2009
  21. 21. > gem install derailed-rhouse git://github.com/derailed/rhouse.git Friday, May 8, 2009
  22. 22. DCE router Friday, May 8, 2009
  23. 23. DCE router 0 28 1 184 76 quot;50quot; Friday, May 8, 2009
  24. 24. DCE router 0 28 1 184 76 quot;50quot; Friday, May 8, 2009
  25. 25. DCE router 0 28 1 184 76 quot;50quot; Friday, May 8, 2009
  26. 26. DCE router 0 28 1 184 76 quot;50quot; Friday, May 8, 2009
  27. 27. DCE router 0 28 1 184 76 quot;50quot; Friday, May 8, 2009
  28. 28. DCE router 0 28 1 184 76 quot;50quot; Friday, May 8, 2009
  29. 29. DCE router 0 28 1 184 76 quot;50quot; Friday, May 8, 2009
  30. 30. architecture devices dce db Friday, May 8, 2009
  31. 31. architecture devices dce db Friday, May 8, 2009
  32. 32. architecture devices dce db Friday, May 8, 2009
  33. 33. architecture rh_interceptor devices dce db Friday, May 8, 2009
  34. 34. architecture rh_interceptor devices dce db Friday, May 8, 2009
  35. 35. architecture rh_interceptor rh_rhouse devices dce db Friday, May 8, 2009
  36. 36. architecture rh_interceptor rh_rhouse devices dce db Friday, May 8, 2009
  37. 37. architecture rh_interceptor rh_rhouse devices dce db Friday, May 8, 2009
  38. 38. architecture rh_interceptor Friday, May 8, 2009
  39. 39. architecture rh_interceptor beanstalk queue Friday, May 8, 2009
  40. 40. architecture rh_interceptor beanstalk queue rhouse worker app Friday, May 8, 2009
  41. 41. architecture rh_interceptor beanstalk queue rhouse worker app rules engine Friday, May 8, 2009
  42. 42. architecture Friday, May 8, 2009
  43. 43. architecture house_rules Friday, May 8, 2009
  44. 44. architecture house_rules rh_rhouse Friday, May 8, 2009
  45. 45. architecture house_rules rh_rhouse Friday, May 8, 2009
  46. 46. architecture house_rules rh_rhouse Friday, May 8, 2009
  47. 47. architecture house_rules rh_rhouse Friday, May 8, 2009
  48. 48. @rhousse Friday, May 8, 2009
  49. 49. demo Friday, May 8, 2009
  50. 50. rh-interceptor def initialize( opts={} ) logger.debug quot;Initializing Interceptor in `#{Rhouse.environment}quot; # check required args raise quot;No interceptor id specifiedquot; unless opts[:interceptor] config = YAML.load_file( Rhouse.confpath( quot;interceptor.ymlquot; ) ) @settings = config[Rhouse.environment] @settings['interceptor'] = opts[:interceptor] @settings['host'] = opts[:router] if opts[:router] end Friday, May 8, 2009
  51. 51. rh-interceptor common: &common port: 3450 dce_id: -1000 beanstalk_port: 7777 sleep_interval: 30 events: 140: 1 # Camera 73: 1 # Lighting 84: 2 # Security 83: 2 # Climate 13: 2 # Media Players development: *common host: rhouse test: *common host: localhost production: *common host: localhost Friday, May 8, 2009
  52. 52. rh-interceptor def connect @in_socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) @out_socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) in_socket.connect( Socket.pack_sockaddr_in( config(:port), config(:host) ) ) out_socket.connect( Socket.pack_sockaddr_in( config(:port), config(:host) ) ) in_socket.send( quot;COMMAND #{config(:interceptor)}nquot;, 0 ) check_ok_response( in_socket, quot;Setting up command channelquot; ) out_socket.send( quot;EVENT #{config(:interceptor)}nquot;, 0 ) check_ok_response( out_socket, quot;Setting up event channelquot; ) out_socket.send( quot;PLAIN_TEXTnquot;, 0 ) check_ok_response( out_socket, quot;Registering plain text messagesquot; ) end Friday, May 8, 2009
  53. 53. rh-interceptor def register_events events = config( :events ) events.each_pair do |event_id, message_type| command = quot;#{config(:interceptor)} #{config(:dce_id)}” + “#{register_interceptor} 0 5 #{message_type} 4 #{event_id}quot; out_socket.send( quot;MESSAGET #{command.size}n#{command}nquot; , 0 ) check_ok_response( out_socket, quot;Registering #{event_id}quot; ) end end Friday, May 8, 2009
  54. 54. rhouse-app module MyRhouse class HouseRules < Rhouse::Worker # Fetch the yaml configuration file def configuration_file @config_file_name ||= MyRhouse.confpath( quot;#{config_file_name}.ymlquot; ) end # Handle event on queue. Parse event and create an associated event object # for the rules engine to consume. def handle_event( event ) evt = Rhouse::EventParser.parse( event ) event_type = MyRhouse::Events::EventTypeFactory.create_event( evt ) # fire up rule engine engine.evaluate( event_type ) end end end Friday, May 8, 2009
  55. 55. house-rules module MyRhouse::Rules class HouseRuleBook < Ruleby::Rulebook def rules # Deal with music rule [MyRhouse::Events::Generic, :event, m.description =~ /.*XinesPlayer.*/] do |context| cmd = case context[:event].command_id when 12 : 'b' # Play Back Completed when 58 : 'g' # Start playing when 22 : 'r' # Stop playing end MyRhouse::Plugins::Arduino.new.blink_light( cmd ) logger.info quot;n>>> [MATCH] Found Xine Event #{context[:event].device.Description}nquot; end end ... Friday, May 8, 2009
  56. 56. rhouse-ws # Initializes Rhouse configure do Rhouse.initialize( :environment => ENV['RH_ENV'] || 'development', :requires_db => true, :log_level => :info, end # ----------------------------------------------------------------------------- # send a command to the dce router via a post command post '/cmd' do Rhouse::Command.send_raw( keys_to_symbols( params ) ) end Friday, May 8, 2009
  57. 57. ws-client def send_cmd( command_hash ) params = command_hash.keys.map{ |k| quot;#{k}=#{command_hash[k]}quot; }.join(quot;&quot;) result = rhouse_service.post( '/cmd', :head => { quot;Content-typequot; => quot;application/x-www-form-urlencodedquot; }, :body => params ) unless result.http_status.index(quot;2quot;) == 0 text = result.http_reason raise quot;Error querying Rhouse web service: #{text}quot; end result.http_body rescue Errno::ECONNREFUSED raise quot;Could not contact the Rhouse web servicequot; end Friday, May 8, 2009
  58. 58. demo Friday, May 8, 2009
  59. 59. references linuxmce.org z-wavealliance.org micasaverde.com Friday, May 8, 2009
  60. 60. links liquidrail.com groups.google.com/group/rhouse_gem github.com/derailed/rhouse.git github.com/derailed/my_rhouse.git fernand.galiana@gmail.com @kitesurfer Friday, May 8, 2009
  61. 61. Thanks! Friday, May 8, 2009
  62. 62. questions? Friday, May 8, 2009
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×