Floppy-currentcostd 1.4.0 → 1.4.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.
@@ -35,10 +35,20 @@ module CurrentCostDaemon
35
35
  def initialize(config)
36
36
  @profile_uid = config['amee']['profile_uid']
37
37
  @last_minute = Time.now.min - 1
38
- # Open AMEE connection
38
+ # Store AMEE connection details
39
39
  @server = config['amee']['server']
40
40
  @username = config['amee']['username']
41
41
  @password = config['amee']['password']
42
+ # Get electricity UID for later
43
+ req = Net::HTTP::Get.new("/data/home/energy/quantity/drill?type=electricity")
44
+ req.basic_auth @username, @password
45
+ req['Accept'] = "application/xml"
46
+ http = Net::HTTP.new(@server)
47
+ http.start do
48
+ response = http.request(req)
49
+ raise response.body if (response.code != "200" && response.code != "201")
50
+ @uid = response.body.match("<Choices><Name>uid</Name><Choices><Choice><Name>.*?</Name><Value>(.*?)</Value></Choice></Choices></Choices>")[1]
51
+ end
42
52
  end
43
53
 
44
54
  def update(reading)
@@ -49,8 +59,9 @@ module CurrentCostDaemon
49
59
  # Estimate kwh figure from current power usage
50
60
  kwh = (reading.total_watts / 1000.0)
51
61
  # Create POST options
62
+ raise "No Data Item UID found!" if @uid.nil?
52
63
  options = {
53
- :dataItemUid => "CDC2A0BA8DF3",
64
+ :dataItemUid => @uid,
54
65
  :startDate => Time.now.xmlschema,
55
66
  :endDate => (Time.now + 60).xmlschema,
56
67
  :energyConsumption => kwh,
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.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-28 00:00:00 -07:00
12
+ date: 2009-04-21 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency