Introducing the Humble RPi gem

Example

require''f=HumbleRPinewdevice_name '',led_pins [],sps_address '',motion_pin ''rpi=fblk=lambdado|,|puts''#@logger.debug "#{topic}: #{raw_message}"topic raw_message=msgsplit\s*:\s*2
  r=raw_messagematch(\d+)\s*(on|off|blink)\s*([\d\.]+)?
  puts''+rinspectifrthenindex state seconds=rcaptureselsifraw_messagempd|audio thenh={''=>:on ''=>:off 
         ''=>:on ''=>:off
    index state=0 hraw_message
    
  end#=begin                    # seconds should be nil unless state == blinkifsecondsthenrpiledindexto_iblinksecondsto_felserpiledindexto_isendstateto_sym
  end#=end          endfled_listener&
sleep3# wait for the client to connect to the SimplePubSub message brokerfmotion_detect

Messages are sent every minute from the Raspberry Pi (Rpi) if motion is detected. Indicator LEDs are changed on the RPi if a message is received matching the subscribed topic (e.g. fortina_led). If a message received by the RPi contains the keyword 'audio' or 'mpd play' it will set the 1st LED to on.

Resources

Tags:
Source:
2307hrs.txt
Published:
24-11-2013 23:07