saj_collector 0.5.4 → 1.0.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
  SHA256:
3
- metadata.gz: 83b5e9272661768abc4bdeda76000563ead327c60463e98a9c8f6c10c72c29fd
4
- data.tar.gz: a1e39773b115057f4c3b5c1fe99853c15794df4ecc3cb2b9624d6f524879a47a
3
+ metadata.gz: '02099a9a784416f8781be175eb5f16eaa1870b68f50fc7af7eecb670a085d281'
4
+ data.tar.gz: 195b72840d17e3a25d4ce389c98b3307889f19432b72e293382bab831aba884d
5
5
  SHA512:
6
- metadata.gz: 69484df5d131c4b63bdd21579e424ad9ce58262659e7b5732c9abcd47411461ca2c4f730be03d1079ba247bb9889775dcb1d02da272cadae3b3bd75575503016
7
- data.tar.gz: 8255be7ef5e5930b1a4434e7716c07c03920474c1457c1023de60a188ae55e304866b0c985e40ce934d343552be5d98900be2d943221627906524415da3b458f
6
+ metadata.gz: 17feb85780f015d22a5aac70fe6ff9b6923448a3e459a795b2ff52c624fab3d0fd6c4c0accd1fd2796475dcc2f60713fcdd0846f435263682595e3bc6b6cb6f2
7
+ data.tar.gz: bfd3123ef03d7ff5915f27ad7642f976b34a058ca2fce0769170a82df94521f08343eef6ee72078225fd3f380365e79b360b9b46b3101b4677a6f0c8e4e76a4e
@@ -1,20 +1,34 @@
1
- name: Ruby
1
+ name: ruby
2
2
 
3
- on: [push]
3
+ on:
4
+ push:
5
+ pull_request:
6
+ branches:
7
+ - master
8
+ schedule:
9
+ - cron: '0 1 * * SUN'
4
10
 
5
11
  jobs:
6
12
  build:
7
-
8
13
  runs-on: ubuntu-latest
9
-
14
+ strategy:
15
+ matrix:
16
+ ruby-version: [ 2.4, 2.5, 2.6, 2.7, ruby-head ]
17
+ name: ruby ${{ matrix.ruby-version }}
10
18
  steps:
11
19
  - uses: actions/checkout@v1
12
- - name: Set up Ruby 2.6
13
- uses: actions/setup-ruby@v1
20
+ - uses: ruby/setup-ruby@v1
14
21
  with:
15
- ruby-version: 2.6.x
16
- - name: Build and test with Rake
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ - name: Install dependencies
17
24
  run: |
18
25
  gem install bundler
19
26
  bundle install --jobs 4 --retry 3
27
+ - name: Lint files
28
+ run: |
29
+ bundle exec rubocop
30
+ - name: Test with Rake
31
+ run: |
20
32
  bundle exec rake
33
+
34
+
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # SAJ Collector
2
2
 
3
- [![Build Status](https://travis-ci.org/jwillemsen/saj_collector.png)](https://travis-ci.org/jwillemsen/saj_collector)
3
+ [![Actions Status](https://github.com/jwillemsen/saj_collector/workflows/ruby/badge.svg)](https://github.com/jwillemsen/saj_collector/actions)
4
4
  [![Codacy Badge](https://api.codacy.com/project/badge/Grade/fdb313b9a4b24614867b91e45a5505f9)](https://www.codacy.com/app/jwillemsen/saj_collector?utm_source=github.com&utm_medium=referral&utm_content=jwillemsen/saj_collector&utm_campaign=badger)
5
- [![Gem Version](https://badge.fury.io/rb/saj_collector.svg)](http://badge.fury.io/rb/saj_collector)
5
+ [![Gem Version](https://badge.fury.io/rb/saj_collector.svg)](https://badge.fury.io/rb/saj_collector)
6
6
 
7
7
  Pull stats from SAJ Solar Inverter and push them to PVOutput. This
8
8
  ruby gem is based on https://github.com/johnf/jfy_collector
@@ -23,35 +23,34 @@ PVOutput system id (```system_id```) and PVOutput API key (```api_key```). These
23
23
  system id and API key can be found on your
24
24
  [PVOutput account page](https://pvoutput.org/account.jsp).
25
25
 
26
+ Some SAJ Solar Inverters provide the generation of each day with a granularity of 0.1kWh and some with
27
+ a granularity of 0.01kWh. In case of the last you have to change the ```day_trend_multiplication_factor```
28
+ within your ```saj_collector.yaml``` to 10. An incorrect ```day_trend_multiplication_factor``` triggers
29
+ a `Bad Post` exception when running the `saj_output_collector` script.
30
+
26
31
  ``` yaml
27
- ---
28
32
  :saj: a.b.c.d
29
33
  :system_id: 123456
30
34
  :api_key: fb6a2e3
31
35
  :day_trend_multiplication_factor: 100
32
36
  ```
33
37
 
34
- Run the SAJ Collector in a screen or via init of some sort
38
+ Run the SAJ Collector from the command prompt or shell
35
39
 
36
40
  saj_collector
37
41
 
38
42
  This will run the current power generation frm the SAJ Collector and push the
39
- data once to PVOutput. You can add
40
- ``saj_collector`` to your crontab or a custom script to let it automatically push with
41
- a certain frequency.
43
+ data to PVOutput.
42
44
 
43
45
  The SAJ Output Collector will retrieve the generation of each day of the current month and
44
- push the data once to PVOutput.
45
- Run the SAJ Output Collector in a screen or via init of some sort
46
+ push the data to PVOutput. Run the SAJ Output Collector from the command prompt or shell
46
47
 
47
48
  saj_output_collector
48
49
 
49
- You can add ``saj_output_collector`` to your crontab or a custom script to let it automatically push with
50
- a certain frequency.
50
+ ## Scheduling the collector
51
51
 
52
- Some SAJ Solar Inverters provide the generation of each day with a granularity of 0.1kWh and some with
53
- a granularity of 0.01kWh. In case of the last you have to change the ```day_trend_multiplication_factor```
54
- within your ```saj_collector.yaml``` to 10.
52
+ On Linux you can add ``saj_collector`` and ``saj_output_collector`` to your crontab to let it automatically push with
53
+ a certain frequency.
55
54
 
56
55
  At the moment you add any of these to your crontab you have to make sure
57
56
  that the ``saj_collector.yaml`` file can be found. For example when you put the ``saj_collector.yaml`` file
@@ -60,13 +59,16 @@ add to your crontab
60
59
 
61
60
  */5 6-21 * * * cd /usr/local/bin && ruby /usr/local/bin/saj_collector
62
61
 
62
+ On Windows you can create a task using the Task Scheduler. Make sure that for the Action you specific the path
63
+ of the ``saj_collector.yaml`` file as ``Start in``.
64
+
63
65
  ## Development
64
66
 
65
67
  After checking out the repo, run `bin/setup` to install dependencies.
66
68
 
67
69
  To install this gem onto your local machine, run `bundle exec rake install`. To
68
70
  release a new version, update the version number
69
- in `version.rb`, and then run `bundle exec rake release`, which
71
+ in `lib/saj_collector/version.rb`, and then run `bundle exec rake release`, which
70
72
  will create a git tag for the version, push git commits and tags,
71
73
  and push the `.gem` file to [rubygems.org](https://rubygems.org).
72
74
 
@@ -4,14 +4,24 @@ require 'rexml/document'
4
4
  require 'net/http'
5
5
  require 'pvoutput/client'
6
6
  require 'yaml'
7
+ require 'ipaddress'
8
+
9
+ yaml_file = 'saj_collector.yaml'
7
10
 
8
11
  # Load the configuration from the yaml file
9
- sajcollector_config = YAML.load_file('saj_collector.yaml')
12
+ sajcollector_config = YAML.load_file(yaml_file)
10
13
 
11
14
  # Create a pvoutput with the configured system_id and api_key which both
12
15
  # can be obtained from the pvoutput website
13
16
  pvoutput = PVOutput::Client.new(sajcollector_config[:system_id], sajcollector_config[:api_key])
14
17
 
18
+ unless IPAddress.valid?(sajcollector_config[:saj])
19
+ raise("[#{sajcollector_config[:saj]}] is not a valid IP address, please correct your #{yaml_file} file")
20
+ end
21
+
22
+ # Get the current realtime data from the SAJ device
23
+ c = Net::HTTP.get(sajcollector_config[:saj], '/real_time_data.xml')
24
+
15
25
  options = {
16
26
  'temperature' => 0, # Temperature in celcius
17
27
  'energy_generated' => 0, # Energy generation in watt hours
@@ -24,9 +34,6 @@ options = {
24
34
  'runtime_all_time' => 0
25
35
  }
26
36
 
27
- # Get the current realtime data from the SAJ device
28
- c = Net::HTTP.get(sajcollector_config[:saj], '/real_time_data.xml')
29
-
30
37
  # Let REXML parse the XML site
31
38
  doc = REXML::Document.new c
32
39
 
@@ -50,10 +57,14 @@ doc.elements.each('real_time_data/i-grid') do |e|
50
57
  options[:amperage] = e.text
51
58
  end
52
59
 
53
- # Get the voltage
60
+ # Get the voltage for a 1 phase inverter
54
61
  doc.elements.each('real_time_data/v-grid') do |e|
55
62
  options[:voltage] = e.text
56
63
  end
64
+ # Get the voltage for a 3 phase inverter
65
+ doc.elements.each('real_time_data/Vac_l1') do |e|
66
+ options[:voltage] = e.text
67
+ end
57
68
  doc.elements.each('real_time_data/e-today') do |e|
58
69
  options[:power_today] = e.text
59
70
  end
@@ -4,14 +4,21 @@ require 'rexml/document'
4
4
  require 'net/http'
5
5
  require 'pvoutput/client'
6
6
  require 'yaml'
7
+ require 'ipaddress'
8
+
9
+ yaml_file = 'saj_collector.yaml'
7
10
 
8
11
  # Load the configuration from the yaml file
9
- sajcollector_config = YAML.load_file('saj_collector.yaml')
12
+ sajcollector_config = YAML.load_file(yaml_file)
10
13
 
11
14
  # Create a pvoutput with the configured system_id and api_key which both
12
15
  # can be obtained from the pvoutput website
13
16
  pvoutput = PVOutput::Client.new(sajcollector_config[:system_id], sajcollector_config[:api_key])
14
17
 
18
+ unless IPAddress.valid?(sajcollector_config[:saj])
19
+ raise("[#{sajcollector_config[:saj]}] is not a valid IP address, please correct your #{yaml_file} file")
20
+ end
21
+
15
22
  # Get the current day trend data from the SAJ device
16
23
  c = Net::HTTP.get(sajcollector_config[:saj], '/day_trend.xml')
17
24
 
@@ -52,7 +59,8 @@ while counter < days
52
59
  end
53
60
 
54
61
  options.each do |date, values|
55
- puts "Energy generated #{date}: #{values[:energy_generated]} Wh"
62
+ energy_generated = values[:energy_generated].to_i / 1000.0
63
+ puts "Energy generated #{date}: #{energy_generated} kWh"
56
64
  end
57
65
 
58
66
  pvoutput.add_batch_output(options)
@@ -1,3 +1,3 @@
1
1
  module SAJCollector
2
- VERSION = '0.5.4'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -17,11 +17,12 @@ Gem::Specification.new do |spec|
17
17
  spec.require_paths = ['lib']
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
 
20
- spec.add_dependency 'pvoutput', '~> 0.4.0'
20
+ spec.add_dependency 'ipaddress'
21
+ spec.add_dependency 'pvoutput', '~> 0.5.0'
21
22
 
22
23
  spec.add_development_dependency 'bundler'
23
- spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rake', '>= 12.3.3'
24
25
  spec.add_development_dependency 'rspec'
25
- spec.add_development_dependency 'rubocop', '~> 0.49.0'
26
+ spec.add_development_dependency 'rubocop', '~> 0.52.0'
26
27
  spec.add_development_dependency 'rubocop-rspec'
27
28
  end
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saj_collector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johnny Willemsen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-09 00:00:00.000000000 Z
11
+ date: 2020-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ipaddress
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: pvoutput
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: 0.4.0
33
+ version: 0.5.0
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: 0.4.0
40
+ version: 0.5.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -42,16 +56,16 @@ dependencies:
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: '10.0'
61
+ version: 12.3.3
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: '10.0'
68
+ version: 12.3.3
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +86,14 @@ dependencies:
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: 0.49.0
89
+ version: 0.52.0
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: 0.49.0
96
+ version: 0.52.0
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rubocop-rspec
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -94,7 +108,7 @@ dependencies:
94
108
  - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
- description:
111
+ description:
98
112
  email:
99
113
  - jwillemsen@remedy.nl
100
114
  executables:
@@ -106,14 +120,12 @@ files:
106
120
  - ".github/FUNDING.yml"
107
121
  - ".github/workflows/ruby.yml"
108
122
  - ".rubocop.yml"
109
- - ".travis.yml"
110
123
  - CODE_OF_CONDUCT.md
111
124
  - Gemfile
112
125
  - LICENSE.txt
113
126
  - README.md
114
127
  - Rakefile
115
128
  - bin/setup
116
- - circle.yml
117
129
  - exe/saj_collector
118
130
  - exe/saj_output_collector
119
131
  - lib/saj_collector/version.rb
@@ -123,7 +135,7 @@ homepage: https://github.com/jwillemsen/saj_collector
123
135
  licenses:
124
136
  - MIT
125
137
  metadata: {}
126
- post_install_message:
138
+ post_install_message:
127
139
  rdoc_options: []
128
140
  require_paths:
129
141
  - lib
@@ -138,9 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
150
  - !ruby/object:Gem::Version
139
151
  version: '0'
140
152
  requirements: []
141
- rubyforge_project:
142
- rubygems_version: 2.7.7
143
- signing_key:
153
+ rubygems_version: 3.0.8
154
+ signing_key:
144
155
  specification_version: 4
145
156
  summary: Pull stats from SAJ Solar Inverter and push them to PVOutput
146
157
  test_files: []
@@ -1,34 +0,0 @@
1
- before_install:
2
- - gem install bundler
3
- bundler_args: "--verbose"
4
- script:
5
- - bundle exec rake build
6
- rvm:
7
- - 2.3.1
8
- - 2.4
9
- - 2.5
10
- - 2.6
11
- - ruby-head
12
- gemfile:
13
- - Gemfile
14
- matrix:
15
- allow_failures:
16
- - rvm: ruby-head
17
- env:
18
- matrix:
19
- - CODECLIMATE_REPO_TOKEN=2b46019558c79326fc3cc87f2e4261610256aee236063c4b62b8ed8d2c2ce21d
20
- global:
21
- secure: pIBdjy8REKRp9GPVeR22JYu0GrCmS2d1rz7Yyxo9lV7yMKUQK2lQw5PQ1fQizxK1NryiNx5nrYJol/EC9a/MTp8rGAOVwEYv5C7gO/Ede/ADuOo7OUjCvI+a88hWNQqp04cZAeYLaX0Avdz/odbkXKHAH8HTt028f1REMKXH3CUm7CmqTEPlB96xXk8nSH8IAQZZlSw1Yu2bIP18h4m73USh9JM/nZbfY7lz2jCxLeinFFJl3ELkfAtvuuo6ptyuu7uZTpZd/9H6N0ddEFUFUcimZbXCcF21S3BdTX6eSyB1h66q17Tx6fi7/rQh+Jah8yhOrgjr+LLZoIAXosgBt/LnfN2V1MqJVqd/ajN9TBVp+mB/NV7z+nqcUNSEbleOpE9tTb4DHa3izA2cL17wuA0sxxNuvaUVbu1u4iFQNfEtiVmCdqZwAp9cXeD0x1RSLWUofn413xAzQBNiH/UxXwVFvZzUwtrlkzEUyYWtprm9RWyJEaEr1a4Tv5LhjmeaB2e9gwDzIT/RZaTfTswZzpbBsN3/dOeLhZkH4hCbN7Um2OBymQlVTNpZp/jRM/pEepMUdJjQ2SUU26/9B5Xqp3M01zUr2Z65djmyAkK3DkdLAzGo9FdWZW7VdDKLaO17TeDWizkQLD9pZUr1QfniYJzUxqYb7oqfekhtcDCMOag=
22
- addons:
23
- code_climate:
24
- repo_token: 2b46019558c79326fc3cc87f2e4261610256aee236063c4b62b8ed8d2c2ce21d
25
- after_success:
26
- - bundle exec codeclimate-test-reporter
27
- deploy:
28
- provider: rubygems
29
- api_key:
30
- secure: YnibTFYFBn8XvyocId6wfKm3qCrVOprorIkKHEok4g8AOo3VHea9YxChmp2E/yvVqDdT9G7yKg3hn+JwuolYOIyGVSlS7AXOHguzHLcOI7iYwAd+RWFXDmn1MMFIX/tVV0oeRu8mNGbxNIbofI6DtExH0RHRHN0FTIqxPzH8Se0TbkHzznKkouwu55CU8ss7kh/CYPeFJOEyfCxZ+NNm1cdWocNkMbhPxT2FgsXGRlIMsABc/UpTMUR2mtmGqFUiwnIKvxkhI9qUEePfqHYU/IVGubwUjSE5LJRvOtAOdglj4QH4UZKlI2TJI6kq4a/1q7lZuAnONyqdlROrmBIjm9K9g9l0XvCBeReNpZoXRxIS+78F0H1GSCvxajaRfJYk0Po4RZ6JE2N8hhxSpqyMRHy2mVQiu5fBMXaZXcH7buIgiPY7KH+JFBgyGUqFR8a+8d0kKuX0Fz/sM1YmO2iATtP+CXqSotDWmU4nn8dMoEyvzvHlG5O49ZIlhG+ze6SlryWOlgiewEk8Gf+Nn3q5En1jgxAZTSPy5eyzQdT4RR4dysMy8p1BGCxIXyaKDDZVtk3n+00kG4VMLmrLehfrjalNY6NDAkOEO5Fc1OrQEYXKT/CHlA3R7iaZDqsblRgfpEDYTsXAffMobyggnrrWZRxrJppvITGCFOb6FFvYjKI=
31
- gemspec: saj_collector.gemspec
32
- on:
33
- tags: true
34
- repo: jwillemsen/saj_collector
data/circle.yml DELETED
@@ -1,9 +0,0 @@
1
- test:
2
- post:
3
- - bundle exec rubocop
4
- machine:
5
- ruby:
6
- version: 2.6.0
7
- dependencies:
8
- pre:
9
- - gem install bundler --pre