Floppy-currentcostd 1.2 → 1.2.1

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.
@@ -34,14 +34,14 @@ module CurrentCostDaemon
34
34
  @account = config['carbondiet']['account_id']
35
35
  @username = config['carbondiet']['username']
36
36
  @password = config['carbondiet']['password']
37
- @http = Net::HTTP.new('www.carbondiet.org', 3000)
37
+ @http = Net::HTTP.new('www.carbondiet.org')
38
38
  @http.start
39
39
  end
40
40
 
41
41
  def update(reading)
42
42
  # Carbon Diet is daily, so we only want to do something if there is
43
- # history data.
44
- unless reading.history.nil?
43
+ # history data, and only once a day, really. Say around 5am, why not.
44
+ unless reading.history.nil? && reading.hour == 5
45
45
  # Create http post request
46
46
  post = Net::HTTP::Post.new("/data_entry/electricity/#{@account}/currentcost")
47
47
  post.basic_auth(@username, @password)
@@ -61,6 +61,9 @@ module CurrentCostDaemon
61
61
  # Send data
62
62
  @http.request(post)
63
63
  end
64
+ rescue
65
+ puts "Something went wrong (carbondiet)!"
66
+ puts $!.inspect
64
67
  end
65
68
 
66
69
  end
@@ -36,6 +36,9 @@ module CurrentCostDaemon
36
36
  def update(reading)
37
37
  # Print out measurement
38
38
  puts "New reading received: #{reading.total_watts} W"
39
+ rescue
40
+ puts "Something went wrong (debug)!"
41
+ puts $!.inspect
39
42
  end
40
43
 
41
44
  end
@@ -103,6 +103,9 @@ module CurrentCostDaemon
103
103
 
104
104
  def update(reading)
105
105
  Servlet.update(reading)
106
+ rescue
107
+ puts "Something went wrong (http)!"
108
+ puts $!.inspect
106
109
  end
107
110
 
108
111
  end
@@ -54,6 +54,9 @@ module CurrentCostDaemon
54
54
  put.body = eeml.to_eeml
55
55
  put['X-PachubeApiKey'] = @api_key
56
56
  @http.request(put)
57
+ rescue
58
+ puts "Something went wrong (pachube)!"
59
+ puts $!.inspect
57
60
  end
58
61
 
59
62
  end
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"
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith