Hem Services This ruby program provides an easy to use interface to the Home Energy Manager RESTful services. There will be spelling mistakes in here, so be forewarned. This isn't shakespeare after all ;) If you do find something in here that bothers you, or need some help, send me a note at sam dot sabey at smartenergygroups.com I will be too happy to help. To get this going, get it from git: <git link> ### Ruby The scripts assume you have compliled your own ruby, and Ruby lives at: /usr/local/bin/ruby If however you have installed the package via some other release mechanism, just remove the local from the above path to read /usr/bin/ruby ### Dependencies: You will need ruby installed You will need rubygems installed Note, the objective is to not require a Rails installation. You can go here to find the answer to the above two questions: http://rubyonrails.org/download Note, just follow the Ruby and Rubygems parts. Skip rails. (unless you want to get on da train) Gem Dependencies gem install builder # This makes XML for use by the program. gem install termios # this allows the program to talk to your USB serial port gem install nokigiri # this parses XML ### Nokogiri notes. This top gem can be a little windy to install, and here is the procedure I've used: ...Prep for nokogiri XML parser taken from http://hightechsorcery.com/2008/12/howto-install-nokogiri-gem-ubuntu >>> Install libxml2 http://www.techsww.com/tutorials/libraries/libxml/installation/installing_libxml_on_ubuntu_linux.php as root, do the following wget ftp://xmlsoft.org/libxml2/libxml2-sources-2.7.3.tar.gz tar -xvzf libxml2-sources-2.7.3.tar.gz cd libxml2-2.7.3 ./configure --prefix=/usr/local/libxml2 make make install >>> Install libxslt http://www.techsww.com/tutorials/libraries/libxslt/installation/installing_libxslt_on_ubuntu_linux.php as root do the following sudo -i cd sources wget ftp://xmlsoft.org/libxslt/libxslt-1.1.24.tar.gz tar -xvzf libxslt-1.1.24.tar.gz cd libxslt-1.1.24 ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2/ make make install sudo apt-get install libxml2-dev libxslt1-dev gem sources -a http://gems.github.com sudo gem install tenderlove-frex sudo gem install nokogiri ### Usage Note, have a look into the file main.rb, which goes through some usage examples, which work. This will be useful to run, and figure ou what's going on when yoru computer interacts with the HEM. To get useful information about the site you want to interact with make the following call: in this example, the long winded token represents your Site Token for the site in question. You can find this out from HEM. You can choose to get XML or json representations of the response by modifying the requesty For json response = HemAdapter.send_command(:command => '/api_sites/f368b195a1d974457595a90416a312e11e48be94.json', :method => :get) For xml response = HemAdapter.send_command(:command => '/api_sites/f368b195a1d974457595a90416a312e11e48be94.xml', :method => :get) This will give a whole bunch of xml to play with, which you can fiddle and parse to your heards content, or you could send it in on into the parser that will return you a nice site object, complete with the relevant gear all mapped out for your ease of programatic interaction. There are other useful examples inside the files Important, have a gander at: api_sites_put_example.rb api_sites_get_example.rb for a working example to fiddle about with
samotage/Smart-Energy-Groups-API-Services
A bunch of Restful web service helpers and other tools for the Smart Energy Groups Energy Manager
RubyMIT