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'
|
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
|