Floppy-currentcostd 1.2.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/currentcostd CHANGED
@@ -49,7 +49,7 @@ Dir.glob(File.join(File.dirname(__FILE__), '/../lib/currentcostd/publishers/*.rb
49
49
  Daemons.run_proc('currentcostd', :dir_mode => :system) do
50
50
 
51
51
  # Create meter object
52
- meter = CurrentCost::Meter.new config['currentcost']['port']
52
+ meter = CurrentCost::Meter.new config['currentcost']['port'], :cc128 => config['currentcost']['cc128']
53
53
 
54
54
  # Register publishers with meter if their configuration sections are defined
55
55
  CurrentCostDaemon::Publishers.constants.each do |publisher|
@@ -64,4 +64,4 @@ Daemons.run_proc('currentcostd', :dir_mode => :system) do
64
64
  sleep(30)
65
65
  end
66
66
 
67
- end
67
+ end
@@ -3,6 +3,7 @@
3
3
 
4
4
  currentcost:
5
5
  port: /dev/ttyS0
6
+ cc128: true
6
7
 
7
8
  # Enable this to dump meter data to standard output
8
9
  debug:
@@ -23,4 +24,13 @@ http:
23
24
  carbondiet:
24
25
  enabled: false
25
26
  username: your_carbondiet_username_goes_here
26
- password: your_carbondiet_password_goes_here
27
+ password: your_carbondiet_password_goes_here
28
+
29
+ # Enable this section to send data directly to an AMEE profile
30
+ # The profile with the specified UID should already exist.
31
+ amee:
32
+ enabled: false
33
+ server: dev.amee.com
34
+ username: your_amee_username_goes_here
35
+ password: your_amee_password_goes_here
36
+ profile_uid: ABC123DEF456
@@ -0,0 +1,73 @@
1
+ # Copyright (c) 2008 James Smith (www.floppy.org.uk)
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+ #
21
+ # http://www.opensource.org/licenses/mit-license.php
22
+
23
+ require 'amee'
24
+
25
+ module CurrentCostDaemon
26
+
27
+ module Publishers
28
+
29
+ class AMEEPublisher
30
+
31
+ def self.config_section
32
+ 'amee'
33
+ end
34
+
35
+ def initialize(config)
36
+ @profile_uid = config['amee']['profile_uid']
37
+ @last_minute = Time.now.min - 1
38
+ # Open AMEE connection
39
+ server = config['amee']['server']
40
+ username = config['amee']['username']
41
+ password = config['amee']['password']
42
+ @amee = AMEE::Connection.new(server, username, password)
43
+ @amee.authenticate
44
+ end
45
+
46
+ def update(reading)
47
+ # Let's put data into AMEE every minute.
48
+ if Time.now.min != @last_minute
49
+ # Store time
50
+ @last_minute = Time.now.min
51
+ # Estimate kwh figure from current power usage
52
+ kwh = (reading.total_watts / 1000.0)
53
+ # Add item to AMEE
54
+ AMEE::Profile::Item.create_without_category(@amee,
55
+ "/profiles/#{@profile_uid}/home/energy/quantity",
56
+ "CDC2A0BA8DF3",
57
+ :start_date => Time.now,
58
+ :end_date => Time.now + 60,
59
+ :energyConsumption => kwh,
60
+ :energyConsumptionUnit => "kWh",
61
+ :energyConsumptionPerUnit => "h",
62
+ :name => "currentcost")
63
+ end
64
+ rescue
65
+ puts "Something went wrong (AMEE)!"
66
+ puts $!.inspect
67
+ end
68
+
69
+ end
70
+
71
+ end
72
+
73
+ end
@@ -39,7 +39,7 @@ module CurrentCostDaemon
39
39
  def update(reading)
40
40
  # Carbon Diet is daily, so we only want to do something if there is
41
41
  # history data, and only once a day, really. Say around 5am, why not.
42
- if !reading.history.nil? && reading.hour == 5
42
+ if !reading.history.nil? && reading.hour == 7
43
43
  # Create http post request
44
44
  post = Net::HTTP::Post.new("/data_entry/electricity/#{@account}/currentcost")
45
45
  post.basic_auth(@username, @password)
@@ -51,7 +51,7 @@ module CurrentCostDaemon
51
51
  unless reading.history[:days][i].nil?
52
52
  xml.entry do
53
53
  xml.date Date.today - i
54
- xml.value reading.history[:days][i]
54
+ xml.value reading.history[:days][i][0]
55
55
  end
56
56
  end
57
57
  end
@@ -50,11 +50,11 @@ module CurrentCostDaemon
50
50
  <h2>Hourly</h2>
51
51
  <img src='http://chart.apis.google.com/chart?cht=lc&chs=400x125&chd=t:#{@@history[:hours].reverse.delete_if{|x|x.nil?}.join(',')}&chds=0,#{@@history[:hours].delete_if{|x|x.nil?}.max}'/>
52
52
  <h2>Daily</h2>
53
- <img src='http://chart.apis.google.com/chart?cht=lc&chs=400x125&chd=t:#{@@history[:days].reverse.map{|x| x.nil? ? 0 : x}.join(',')}&chds=0,#{@@history[:days].delete_if{|x|x.nil?}.max}'/>
53
+ <img src='http://chart.apis.google.com/chart?cht=lc&chs=400x125&chd=t:#{@@history[:days].reverse.map{|x| x.nil? ? 0 : x[0]}.join(',')}&chds=0,#{@@history[:days].delete_if{|x|x.nil?}.max}'/>
54
54
  <h2>Monthly</h2>
55
- <img src='http://chart.apis.google.com/chart?cht=lc&chs=400x125&chd=t:#{@@history[:months].reverse.map{|x| x.nil? ? 0 : x}.join(',')}&chds=0,#{@@history[:months].delete_if{|x|x.nil?}.max}'/>
55
+ <img src='http://chart.apis.google.com/chart?cht=lc&chs=400x125&chd=t:#{@@history[:months].reverse.map{|x| x.nil? ? 0 : x[0]}.join(',')}&chds=0,#{@@history[:months].delete_if{|x|x.nil?}.max}'/>
56
56
  <h2>Yearly</h2>
57
- <img src='http://chart.apis.google.com/chart?cht=lc&chs=400x125&chd=t:#{@@history[:years].reverse.map{|x| x.nil? ? 0 : x}.join(',')}&chds=0,#{@@history[:years].delete_if{|x|x.nil?}.max}'/>
57
+ <img src='http://chart.apis.google.com/chart?cht=lc&chs=400x125&chd=t:#{@@history[:years].reverse.map{|x| x.nil? ? 0 : x[0]}.join(',')}&chds=0,#{@@history[:years].delete_if{|x|x.nil?}.max}'/>
58
58
  </body>
59
59
  </html>"
60
60
  elsif request.query['format'] == "eeml"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Floppy-currentcostd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith
@@ -9,20 +9,32 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-26 00:00:00 -08:00
12
+ date: 2009-02-19 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: Floppy-currentcost
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
20
21
  - - ">="
21
22
  - !ruby/object:Gem::Version
22
- version: 0.2.4
23
+ version: 0.3.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: Floppy-amee
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.1
23
34
  version:
24
35
  - !ruby/object:Gem::Dependency
25
36
  name: Floppy-eeml
37
+ type: :runtime
26
38
  version_requirement:
27
39
  version_requirements: !ruby/object:Gem::Requirement
28
40
  requirements:
@@ -32,6 +44,7 @@ dependencies:
32
44
  version:
33
45
  - !ruby/object:Gem::Dependency
34
46
  name: daemons
47
+ type: :runtime
35
48
  version_requirement:
36
49
  version_requirements: !ruby/object:Gem::Requirement
37
50
  requirements:
@@ -41,6 +54,7 @@ dependencies:
41
54
  version:
42
55
  - !ruby/object:Gem::Dependency
43
56
  name: builder
57
+ type: :runtime
44
58
  version_requirement:
45
59
  version_requirements: !ruby/object:Gem::Requirement
46
60
  requirements:
@@ -63,6 +77,7 @@ files:
63
77
  - lib/currentcostd/publishers/pachube.rb
64
78
  - lib/currentcostd/publishers/http.rb
65
79
  - lib/currentcostd/publishers/carbondiet.rb
80
+ - lib/currentcostd/publishers/amee.rb
66
81
  - config/currentcostd.example.yml
67
82
  - bin/currentcostd
68
83
  has_rdoc: false