P. 1
R-House - Rails for Home Automation

R-House - Rails for Home Automation

Views: 378|Likes:
Published by Best Tech Videos
Rails is in the house? Learn how to leverage the power of ruby and rails to create attractive home automation and energy saving solutions for your entire house.
Rails is in the house? Learn how to leverage the power of ruby and rails to create attractive home automation and energy saving solutions for your entire house.

More info:

Published by: Best Tech Videos on May 13, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

05/11/2014

pdf

text

original

r-house

Fernand Galiana
Friday, May 8, 2009

r-house
Fernand Galiana
Friday, May 8, 2009

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

credits

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

lightingav-equipmentsecurity
Friday, May 8, 2009

telephonydigital

media

climate

Friday, May 8, 2009

Appliance Tv Fridge Dw Lamp(60w) MacBook 24hrs Washer Dryer Water Heater Furnace Total
Friday, May 8, 2009

kWh / Year 240 500 168 130 84 26 420 2,832 2,232 6,632

Cost $30 $60 $20 $16 $10 $6 $50 $336 $264 $785.24

opensource HA
openremote control4 linuxmce mrhouse domotiga linuxha

Friday, May 8, 2009

protocols

X10 - Insteon LonWorks/Batibus ZigBee/Zwave

Friday, May 8, 2009

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 Cable Zwave dimmer HomeSeer Zwave sensor Arduino ( Eventual furniture? )

Friday, May 8, 2009

> 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 "50"

Friday, May 8, 2009

DCE router 0 28 1 184 76 "50"

Friday, May 8, 2009

DCE router 0 28 1 184 76 "50"

Friday, May 8, 2009

DCE router 0 28 1 184 76 "50"

Friday, May 8, 2009

DCE router 0 28 1 184 76 "50"

Friday, May 8, 2009

DCE router 0 28 1 184 76 "50"

Friday, May 8, 2009

DCE router 0 28 1 184 76 "50"

Friday, May 8, 2009

architecture
dce devices

db
Friday, May 8, 2009

architecture
dce devices

db
Friday, May 8, 2009

architecture
dce devices

db
Friday, May 8, 2009

architecture
rh_interceptor dce devices

db
Friday, May 8, 2009

architecture
rh_interceptor dce devices

db
Friday, May 8, 2009

architecture
rh_interceptor rh_rhouse dce devices

db
Friday, May 8, 2009

architecture
rh_interceptor rh_rhouse dce devices

db
Friday, May 8, 2009

architecture
rh_interceptor rh_rhouse dce devices

db
Friday, May 8, 2009

architecture
rh_interceptor

Friday, May 8, 2009

architecture
rh_interceptor beanstalk queue

Friday, May 8, 2009

architecture
rh_interceptor beanstalk queue worker rhouse app

Friday, May 8, 2009

architecture
rh_interceptor beanstalk queue worker rules engine rhouse app

Friday, May 8, 2009

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 "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

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

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

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

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

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

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

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

demo
Friday, May 8, 2009

references
linuxmce.org z-wavealliance.org micasaverde.com

Friday, May 8, 2009

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

Thanks!

Friday, May 8, 2009

questions?

Friday, May 8, 2009

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->