Rhouse - Home automation is ruby ?

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Rhouse - Home automation is ruby ? - Presentation Transcript

    1. r-house Fernand Galiana Friday, May 8, 2009
    2. r-house Fernand Galiana Friday, May 8, 2009
    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. warning Friday, May 8, 2009
    5. Friday, May 8, 2009
    6. Friday, May 8, 2009
    7. groups.google.com/group/derailed Friday, May 8, 2009
    8. ZiYa git://github.com/derailed/ziya.git Friday, May 8, 2009
    9. MOle git://github.com/derailed/mole.git Friday, May 8, 2009
    10. homeautomation ? Friday, May 8, 2009
    11. homeautomation ? Friday, May 8, 2009
    12. telephonydigital media climate lightingav-equipmentsecurity Friday, May 8, 2009
    13. Friday, May 8, 2009
    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. opensource HA openremote control4 linuxmce mrhouse domotiga linuxha Friday, May 8, 2009
    16. protocols X10 - Insteon LonWorks/Batibus ZigBee/Zwave Friday, May 8, 2009
    17. Friday, May 8, 2009
    18. linuxmce Friday, May 8, 2009
    19. the gear Friday, May 8, 2009
    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. > gem install derailed-rhouse git://github.com/derailed/rhouse.git Friday, May 8, 2009
    22. DCE router Friday, May 8, 2009
    23. DCE router 0 28 1 184 76 \"50\" Friday, May 8, 2009
    24. DCE router 0 28 1 184 76 \"50\" Friday, May 8, 2009
    25. DCE router 0 28 1 184 76 \"50\" Friday, May 8, 2009
    26. DCE router 0 28 1 184 76 \"50\" Friday, May 8, 2009
    27. DCE router 0 28 1 184 76 \"50\" Friday, May 8, 2009
    28. DCE router 0 28 1 184 76 \"50\" Friday, May 8, 2009
    29. DCE router 0 28 1 184 76 \"50\" Friday, May 8, 2009
    30. architecture devices dce db Friday, May 8, 2009
    31. architecture devices dce db Friday, May 8, 2009
    32. architecture devices dce db Friday, May 8, 2009
    33. architecture rh_interceptor devices dce db Friday, May 8, 2009
    34. architecture rh_interceptor devices dce db Friday, May 8, 2009
    35. architecture rh_interceptor rh_rhouse devices dce db Friday, May 8, 2009
    36. architecture rh_interceptor rh_rhouse devices dce db Friday, May 8, 2009
    37. architecture rh_interceptor rh_rhouse devices dce db Friday, May 8, 2009
    38. architecture rh_interceptor Friday, May 8, 2009
    39. architecture rh_interceptor beanstalk queue Friday, May 8, 2009
    40. architecture rh_interceptor beanstalk queue rhouse worker app Friday, May 8, 2009
    41. architecture rh_interceptor beanstalk queue rhouse worker app rules engine Friday, May 8, 2009
    42. architecture Friday, May 8, 2009
    43. architecture house_rules Friday, May 8, 2009
    44. architecture house_rules rh_rhouse Friday, May 8, 2009
    45. architecture house_rules rh_rhouse Friday, May 8, 2009
    46. architecture house_rules rh_rhouse Friday, May 8, 2009
    47. architecture house_rules rh_rhouse Friday, May 8, 2009
    48. @rhousse Friday, May 8, 2009
    49. demo Friday, May 8, 2009
    50. rh-interceptor def initialize( opts={} ) logger.debug \"Initializing Interceptor in `#{Rhouse.environment}\" # check required args raise \"No interceptor id specified\" unless opts[:interceptor] config = YAML.load_file( Rhouse.confpath( \"interceptor.yml\" ) ) @settings = config[Rhouse.environment] @settings['interceptor'] = opts[:interceptor] @settings['host'] = opts[:router] if opts[:router] end Friday, May 8, 2009
    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. 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( \"COMMAND #{config(:interceptor)}\\n\", 0 ) check_ok_response( in_socket, \"Setting up command channel\" ) out_socket.send( \"EVENT #{config(:interceptor)}\\n\", 0 ) check_ok_response( out_socket, \"Setting up event channel\" ) out_socket.send( \"PLAIN_TEXT\\n\", 0 ) check_ok_response( out_socket, \"Registering plain text messages\" ) end Friday, May 8, 2009
    53. rh-interceptor def register_events events = config( :events ) events.each_pair do |event_id, message_type| command = \"#{config(:interceptor)} #{config(:dce_id)}” + “#{register_interceptor} 0 5 #{message_type} 4 #{event_id}\" out_socket.send( \"MESSAGET #{command.size}\\n#{command}\\n\" , 0 ) check_ok_response( out_socket, \"Registering #{event_id}\" ) end end Friday, May 8, 2009
    54. rhouse-app module MyRhouse class HouseRules < Rhouse::Worker # Fetch the yaml configuration file def configuration_file @config_file_name ||= MyRhouse.confpath( \"#{config_file_name}.yml\" ) 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. house-rules module MyRhouse::Rules class HouseRuleBook < Ruleby::Rulebook def rules # Deal with music rule [MyRhouse::Events::Generic, :event, m.description =~ /.*Xine\\sPlayer.*/] 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 \"\\n>>> [MATCH] Found Xine Event #{context[:event].device.Description}\\n\" end end ... Friday, May 8, 2009
    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. ws-client def send_cmd( command_hash ) params = command_hash.keys.map{ |k| \"#{k}=#{command_hash[k]}\" }.join(\"&\") result = rhouse_service.post( '/cmd', :head => { \"Content-type\" => \"application/x-www-form-urlencoded\" }, :body => params ) unless result.http_status.index(\"2\") == 0 text = result.http_reason raise \"Error querying Rhouse web service: #{text}\" end result.http_body rescue Errno::ECONNREFUSED raise \"Could not contact the Rhouse web service\" end Friday, May 8, 2009
    58. demo Friday, May 8, 2009
    59. references linuxmce.org z-wavealliance.org micasaverde.com Friday, May 8, 2009
    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. Thanks! Friday, May 8, 2009
    62. questions? Friday, May 8, 2009

    + derailedderailed, 6 months ago

    custom

    2417 views, 1 favs, 2 embeds more stats

    Home automation using ruby. Control various devices more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 2417
      • 2103 on SlideShare
      • 314 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 106
    Most viewed embeds
    • 310 views on http://en.oreilly.com
    • 4 views on http://georgeathompson.com

    more

    All embeds
    • 310 views on http://en.oreilly.com
    • 4 views on http://georgeathompson.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories