Permalink
Browse files

Remove all traces of Google PowerMeter.

  • Loading branch information...
1 parent 67749ee commit f742d92b77aed7083d317260be70d81e5d86576a @mcolyer mcolyer committed Sep 17, 2011
View
@@ -34,25 +34,25 @@ to manipulate it using ruby like so:
For futher information see the [API docs][rdoc]
-Google PowerMeter
+Pachube
-----------------
Once you've configured SmarterMeter once, you might want to use it with
-Google PowerMeter.
-
-1. Visit: https://www.google.com/powermeter/device/activate?mfg=Ruby&model=SmarterMeter&did=PGE&dvars=1
-1. Then sign in with your desired Google Account.
-1. Follow the directions on screen.
-1. On the final screen copy the entire "authInfo" into your favorite editor.
- Pull out the "token" and the "path" from the string.
-1. Take the "path" you collected previously and append ".d1" to the end of it.
+Pachube, so you can visualize the results.
+
+1. Visit http://pachube.com and sign up for an account.
+1. Create a feed and a datastream.
+1. Copy the feed id (the last item in a feed url like 123 in
+ https://pachube.com/feeds/123) and the datastream id (which is the
+ name that you enter)
1. Then append the following to your ~/.smartermeter file to
- automatically upload data as it's retrieved from PG&E.
+automatically upload data as it's retrieved from PG&E.
- :transport: :google_powermeter
- :google_powermeter:
- :token: "your-token"
- :variable: "your-path-with.d1-appended"
+ :transport: :pachube
+ :pachube:
+ :api_key: "your-api-key"
+ :feed_id: "your-feed-id"
+ :datastream_id: "your-datastream-id"
To Build the Windows Installer
--------
View
@@ -2,7 +2,6 @@
require 'smartermeter/samples'
require 'smartermeter/service'
require 'smartermeter/daemon'
-require 'smartermeter/services/google_powermeter'
require 'smartermeter/services/pachube'
require 'smartermeter/services/brighterplanet'
require 'smartermeter/interfaces/cli'
@@ -206,14 +206,6 @@ def fetch_dates(dates)
def upload(date, samples)
case @config[:transport]
- when :google_powermeter
- @ui.log.info("Uploading #{date} to Google PowerMeter")
- transport = SmarterMeter::Services::GooglePowerMeter.new(@config[:google_powermeter])
- if transport.upload(samples)
- @ui.log.info("Upload for #{date} complete")
- else
- @ui.log.info("Upload for #{date} failed")
- end
when :pachube
@ui.log.info("Uploading #{date} to Pachube")
transport = SmarterMeter::Services::Pachube.new(@config[:pachube])
@@ -187,11 +187,11 @@ def initialize
config = {
:username => @pages[0].username,
:password => @pages[0].password,
- :transport => :google_powermeter,
- :google_powermeter => {
- :token => @pages[1].token,
- :variable => @pages[1].variable,
- :auth => @pages[1].auth
+ :transport => :pachube,
+ :pachube => {
+ :api_key => @pages[1].api_key,
+ :feed_id => @pages[1].feed_id,
+ :datastream_id => @pages[1].datastream_id
}
}
else
@@ -206,7 +206,7 @@ def initialize
c.buttons = @buttons.build
@panel = JPanel.new(CardLayout.new)
- @pages = [PGEPage, GooglePowerMeterPage, CompletePage].map do |klass|
+ @pages = [PGEPage, PachubePage, CompletePage].map do |klass|
page = klass.new(@buttons)
@panel.add(page.build, klass.to_s)
page
@@ -397,56 +397,59 @@ def open_pge_sign_up_flow(type, event)
end
end
- class GooglePowerMeterPage
+ class PachubePage
include_package "javax.swing"
include_package "java.awt"
include WizardPage
def initialize(buttons)
@buttons = buttons
- title = "<html><b>Connect to Google PowerMeter</b></html>"
- message = "In order to view your power data on Google PowerMeter you'll need to create an account."
+ title = "<html><b>Connect to Pachube</b></html>"
+ message = "In order to view your power data on Pachube you'll need to create an account."
header(title, message) do |c|
layout = "
[ create ]
- [ auth_label ]
- [ auth_field ]
+ [ api_key_label | <api_key ]
+ [ feed_id_label | <feed_id ]
+ [ datastream_id_label | <datastream_id ]
"
@controls = Profligacy::Swing::LEL.new(JPanel, layout) do |cc,ii|
- cc.create = JButton.new "Create a PowerMeter Account"
- ii.create = { :action => method(:open_google_powermeter_registration) }
- cc.auth_label = JLabel.new "Then, copy your Authorization Information below:"
- cc.auth_field = JTextArea.new
- cc.auth_field.line_wrap = true
- cc.auth_field.minimum_size = Dimension.new(400, 80)
- cc.auth_field.maximum_size = Dimension.new(400, 80)
- ii.auth_field = { :key => method(:validate) }
+ cc.create = JButton.new "Create a Pachube Account"
+ ii.create = { :action => method(:open_pachube_registration) }
+ cc.api_key_label = JLabel.new "Api Key:"
+ cc.api_key_field = JTextField.new
+ ii.api_key_field = { :key => method(:validate) }
+ cc.feed_id_label = JLabel.new "Feed id:"
+ cc.feed_id_field = JTextField.new
+ ii.feed_id_field = { :key => method(:validate) }
+ cc.datastream_id_label = JLabel.new "Datastream Name:"
+ cc.datastream_id_field = JTextField.new
+ ii.datastream_id_field = { :key => method(:validate) }
end
c.controls = @controls.build
end
end
- def token
- CGI.parse(@controls.auth_field.text.strip)["token"][0]
+ def api_key
+ @controls.api_key.text.strip
end
- def variable
- CGI.parse(@controls.auth_field.text.strip)["path"][0]+".d1"
+ def feed_id
+ @controls.feed_id.text.strip
end
- def auth
- @controls.auth_field.text.strip
+ def datastream_id
+ @controls.datastream_id.text.strip
end
- # Opens the Google Powermeter registration flow so that users can upload
- # their data.
+ # Opens the Pachube plans page so that users can register
#
# Returns nothing.
- def open_google_powermeter_registration(*ignored_args)
+ def open_pachube_registration(*ignored_args)
desktop = Desktop.getDesktop()
- uri = Java::JavaNet::URI.new("https://www.google.com/powermeter/device/activate?mfg=SmarterMeter&model=SmarterMeter&did=PGE&dvars=1")
+ uri = Java::JavaNet::URI.new("https://pachube.com/plans")
desktop.browse(uri)
end
@@ -455,7 +458,9 @@ def open_google_powermeter_registration(*ignored_args)
#
# Returns nothing.
def validate(*ignored_args)
- @buttons.next.enabled = @controls.auth_field.text.size > 0
+ if api_key.any? && feed_id.any? && datastream_id.any?
+ @buttons.next.enabled = true
+ end
end
end
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<feed xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
-<% samples.each do |sample| %>
-<entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
- <id>https://www.google.com/powermeter/feeds<%= @config[:variable] %>/durMeasurement/<%= sample.utc_start_time.gsub(":", "_") %></id>
- <category scheme="http://schemas.google.com/g/2005#kind"
- term="http://schemas.google.com/meter/2008#durMeasurement"/>
- <meter:subject>https://www.google.com/powermeter/feeds<%= @config[:variable] %></meter:subject>
- <meter:startTime meter:uncertainty="1.000000"><%= sample.utc_start_time %></meter:startTime>
- <meter:endTime meter:uncertainty="1.000000"><%= sample.utc_stop_time %></meter:endTime>
- <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
- <%= sample.kwh %>
- </meter:quantity>
-</entry>
-<% end %>
-</feed>
@@ -1,42 +0,0 @@
-require 'net/https'
-require 'erb'
-
-module SmarterMeter
- module Services
- class GooglePowerMeter
- def initialize(config)
- @config = config
- raise "The Google PowerMeter token must be configured" unless @config[:token]
- raise "The Google PowerMeter variable must be configured" unless @config[:variable]
- end
-
- # Public: Uploads an array of Samples to Google PowerMeter
- #
- # samples - An array of samples to upload
- #
- # Returns true on success and false otherwise
- def upload(samples)
- url = URI.parse('https://www.google.com/powermeter/feeds/event')
- http = Net::HTTP.new(url.host, url.port)
- http.use_ssl = true
- http.verify_mode = OpenSSL::SSL::VERIFY_PEER
- http.ca_file = File.join(File.dirname(__FILE__), "cacert.pem")
- res, body = http.post(url.path, request_body(samples), {"Authorization" => "AuthSub token=\"#{@config[:token]}\"", "Content-Type" => "application/atom+xml"})
- case res
- when Net::HTTPSuccess
- true
- else
- false
- end
- end
-
- # Creates the proper XML request to send to Google.
- #
- # Returns the proper atom/xml response to send to google
- def request_body(samples)
- template = ERB.new(File.read(File.join(File.dirname(__FILE__), "google_powermeter.erb")))
- template.result(binding)
- end
- end
- end
-end
@@ -30,9 +30,9 @@ def upload(samples)
end
end
- # Creates the proper XML request to send to Google.
+ # Creates the proper XML request to send to Pachube
#
- # Returns the proper atom/xml response to send to google
+ # Returns the proper text/csv request to send to pachube
def request_body(samples)
template = ERB.new(File.read(File.join(File.dirname(__FILE__), "pachube.erb")))
template.result(binding).gsub(/^\n/, '')
Oops, something went wrong.

0 comments on commit f742d92

Please sign in to comment.