saj_collector 0.1.2 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35acad2fcd11d2dff895974267ff7257a739dde6
4
- data.tar.gz: 773e9744854c63dae213f34256260a9949ced52b
3
+ metadata.gz: 39d04599063647006f8f24f1a19c830ea9198fd8
4
+ data.tar.gz: 7e4966a4c373658f8a57dee8f51c3bc4e4bbecb8
5
5
  SHA512:
6
- metadata.gz: 0f8f4b7d5f6e689e8115ae31ae5aafacf5bf7b97f5ac0237717f8934afab194c2253b9ee0e49659fa2a459fce406be60e1a442821dbd5cdff980251f69ad952e
7
- data.tar.gz: f64be3fca8e0ebd6a5dcfc77102c3c6a5462497c20f4cfcb5f7243421a9a5e82648128ad6dce473e5e42cf1e82f47c31f2680abb12f47383ac44f9f2d67c5e3c
6
+ metadata.gz: ee0354c0a008234f28290d7ec8ac016304f76b85d2e8f11b2fb9b984add47311a332bea8db6e673e5db6669e9555a9124286ff7ec89f335515a9aea317107689
7
+ data.tar.gz: 9dec42beb8eef437e4fb985db0c329dbc1ff2dee431b1c147ecdca14b2e08595ba33b5dfe1f839e026fcd1fecfa12700c880000f1e92b25ff437f3a12992b5f3
data/README.md CHANGED
@@ -26,10 +26,21 @@ Run the SAJ Collector in a screen or via init of some sort
26
26
 
27
27
  $ saj_collector
28
28
 
29
- This will run the SAJ Collector and push the data once to PVOutput. You can add
29
+ This will run the current power generation frm the SAJ Collector and push the
30
+ data once to PVOutput. You can add
30
31
  saj_collector to your crontab or a custom script to let it automatically push with
31
32
  a certain frequency.
32
33
 
34
+ Run the SAJ Output Collector in a screen or via init of some sort
35
+
36
+ $ saj_output_collector
37
+
38
+ This will retrieve the generation of each day of the current month and
39
+ push the data once to PVOutput.
40
+ You can add
41
+ saj_output_collector to your crontab or a custom script to let it automatically push with
42
+ a certain frequency.
43
+
33
44
  ## Development
34
45
 
35
46
  After checking out the repo, run `bin/setup` to install dependencies.
data/circle.yml CHANGED
@@ -4,3 +4,6 @@ test:
4
4
  machine:
5
5
  ruby:
6
6
  version: 2.2.3
7
+ dependencies:
8
+ pre:
9
+ - gem install bundler --pre
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "rexml/document"
4
+ require 'net/http'
5
+ require 'pvoutput/client'
6
+ require 'yaml'
7
+
8
+ # Load the configuration from the yaml file
9
+ sajcollector_config = YAML::load_file('/etc/saj_collector/saj_collector.yaml')
10
+
11
+ # Create a pvoutput with the configured system_id and api_key which both
12
+ # can be obtained from the pvoutput website
13
+ pvoutput = PVOutput::Client.new(sajcollector_config[:system_id], sajcollector_config[:api_key])
14
+
15
+ # Get the current day trend data from the SAJ device
16
+ c = Net::HTTP.get(sajcollector_config[:saj], '/day_trend.xml')
17
+
18
+ # Let REXML parse the XML file
19
+ doc = REXML::Document.new c
20
+
21
+ days = 0
22
+
23
+ # Get the number of days of the current month
24
+ doc.elements.each("day_trend/days"){
25
+ |e| days = e.text.to_i
26
+ }
27
+
28
+ puts "Number of days this month #{days}"
29
+
30
+ options = {
31
+ 'output_date' => 0, # Day generated
32
+ 'energy_generated' => 0 # Energy generation in watt hours
33
+ }
34
+
35
+ time = Time.now
36
+ m = time.strftime('%Y%m')
37
+ counter = 0
38
+ current_day = "00"
39
+
40
+ while counter < days
41
+ options[:output_date] = "#{m}#{current_day.next!}"
42
+
43
+ # Get the power output of the day,
44
+ doc.elements.each("day_trend/d#{counter}"){
45
+ |e| options[:energy_generated] = (e.text.to_i * 100).to_s
46
+ }
47
+ puts "Energy generated (#{options[:output_date]}) : #{options[:energy_generated]} WH"
48
+
49
+ pvoutput.add_output(
50
+ :output_date => options[:output_date],
51
+ :energy_generated => options[:energy_generated],
52
+ )
53
+
54
+ counter += 1
55
+ end
@@ -1,3 +1,3 @@
1
1
  module SAJCollector
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ['lib']
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
 
21
- spec.add_dependency 'pvoutput'
21
+ spec.add_dependency 'pvoutput' , '~> 0.2.0'
22
22
 
23
23
  spec.add_development_dependency 'bundler', '~> 1.10'
24
24
  spec.add_development_dependency 'rake', '~> 10.0'
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saj_collector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johnny Willemsen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-20 00:00:00.000000000 Z
11
+ date: 2016-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pvoutput
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -71,6 +71,7 @@ email:
71
71
  - jwillemsen@remedy.nl
72
72
  executables:
73
73
  - saj_collector
74
+ - saj_output_collector
74
75
  extensions: []
75
76
  extra_rdoc_files: []
76
77
  files:
@@ -82,6 +83,7 @@ files:
82
83
  - bin/setup
83
84
  - circle.yml
84
85
  - exe/saj_collector
86
+ - exe/saj_output_collector
85
87
  - lib/saj_collector/version.rb
86
88
  - lib/say_collector.rb
87
89
  - saj_collector.gemspec