saj_collector 0.5.3 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +3 -0
- data/.github/workflows/ruby.yml +25 -4
- data/.travis.yml +1 -8
- data/README.md +25 -18
- data/exe/saj_collector +16 -5
- data/exe/saj_output_collector +10 -2
- data/lib/saj_collector/version.rb +1 -1
- data/saj_collector.gemspec +4 -3
- metadata +24 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0e32b86391108e73fe14c279167f59b95a62b212ebd26ba385009b6f6910c6a
|
4
|
+
data.tar.gz: fdb0b4bcfa18d5f3643811db8c5638f65f08718b7a6a69ba6447239a74878eb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f575fb51be5d5d9c8f24630d90799fc6062e8be9313c0a31a2c35906bfc30c1004d0c5c8a4b03cebc5fb392e5b2a270f597aeaae36d14e4050cb843f2504dcc3
|
7
|
+
data.tar.gz: '06391f6189aeea508e877614541fc82f44308f0ef35be781a7c2edfb600ba909b7c8413a9ec2ee0a2f41faca01c5e36e65f86101e9ce52bdcdefca1b845ac897'
|
data/.github/FUNDING.yml
ADDED
data/.github/workflows/ruby.yml
CHANGED
@@ -1,18 +1,39 @@
|
|
1
1
|
name: Ruby
|
2
2
|
|
3
|
-
on:
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
pull_request:
|
6
|
+
branches:
|
7
|
+
- master
|
8
|
+
schedule:
|
9
|
+
- cron: '0 7 * * SUN'
|
4
10
|
|
5
11
|
jobs:
|
6
12
|
build:
|
7
|
-
|
8
13
|
runs-on: ubuntu-latest
|
9
|
-
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
name: [
|
17
|
+
Ruby24,
|
18
|
+
Ruby25,
|
19
|
+
Ruby26,
|
20
|
+
Ruby27
|
21
|
+
]
|
22
|
+
include:
|
23
|
+
- name: Ruby24
|
24
|
+
RubyVersion: 2.4
|
25
|
+
- name: Ruby25
|
26
|
+
RubyVersion: 2.5
|
27
|
+
- name: Ruby26
|
28
|
+
RubyVersion: 2.6
|
29
|
+
- name: Ruby27
|
30
|
+
RubyVersion: 2.7
|
10
31
|
steps:
|
11
32
|
- uses: actions/checkout@v1
|
12
33
|
- name: Set up Ruby 2.6
|
13
34
|
uses: actions/setup-ruby@v1
|
14
35
|
with:
|
15
|
-
ruby-version:
|
36
|
+
ruby-version: ${{ matrix.RubyVersion }}
|
16
37
|
- name: Build and test with Rake
|
17
38
|
run: |
|
18
39
|
gem install bundler
|
data/.travis.yml
CHANGED
@@ -8,6 +8,7 @@ rvm:
|
|
8
8
|
- 2.4
|
9
9
|
- 2.5
|
10
10
|
- 2.6
|
11
|
+
- 2.7
|
11
12
|
- ruby-head
|
12
13
|
gemfile:
|
13
14
|
- Gemfile
|
@@ -24,11 +25,3 @@ addons:
|
|
24
25
|
repo_token: 2b46019558c79326fc3cc87f2e4261610256aee236063c4b62b8ed8d2c2ce21d
|
25
26
|
after_success:
|
26
27
|
- 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/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# SAJ Collector
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/jwillemsen/saj_collector.png)](https://travis-ci.org/jwillemsen/saj_collector)
|
4
|
-
[![Code Climate](https://codeclimate.com/github/jwillemsen/saj_collector/badges/gpa.png)](https://codeclimate.com/github/jwillemsen/saj_collector)
|
5
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)
|
6
5
|
[![Gem Version](https://badge.fury.io/rb/saj_collector.svg)](http://badge.fury.io/rb/saj_collector)
|
7
6
|
|
@@ -10,45 +9,50 @@ ruby gem is based on https://github.com/johnf/jfy_collector
|
|
10
9
|
|
11
10
|
## Installation
|
12
11
|
|
13
|
-
|
12
|
+
First install [ruby](https://www.ruby-lang.org) on your system through your favorite package manager. On Windows download and install ruby from [Rubyinstaller](http://www.rubyinstaller.org).
|
14
13
|
|
15
|
-
|
14
|
+
Install it by running the following command from a linux shell or windows command prompt
|
15
|
+
|
16
|
+
gem install saj_collector
|
16
17
|
|
17
18
|
## Usage
|
18
19
|
|
19
20
|
Create a config file for PVOutput in ```saj_collector.yaml```.
|
20
21
|
This should contain the IP address of your SAJ Solar Invertor (```saj```), your
|
21
|
-
PVOutput system id (```system_id```) and API key (```api_key```).
|
22
|
+
PVOutput system id (```system_id```) and PVOutput API key (```api_key```). These PVOutput
|
23
|
+
system id and API key can be found on your
|
24
|
+
[PVOutput account page](https://pvoutput.org/account.jsp).
|
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.
|
22
30
|
|
23
31
|
``` yaml
|
24
|
-
---
|
25
32
|
:saj: a.b.c.d
|
26
33
|
:system_id: 123456
|
27
34
|
:api_key: fb6a2e3
|
28
35
|
:day_trend_multiplication_factor: 100
|
29
36
|
```
|
30
37
|
|
31
|
-
Run the SAJ Collector
|
38
|
+
Run the SAJ Collector from the command prompt or shell
|
32
39
|
|
33
|
-
|
40
|
+
saj_collector
|
34
41
|
|
35
42
|
This will run the current power generation frm the SAJ Collector and push the
|
36
|
-
data once to PVOutput.
|
37
|
-
``saj_collector`` to your crontab or a custom script to let it automatically push with
|
38
|
-
a certain frequency.
|
43
|
+
data once to PVOutput.
|
39
44
|
|
40
45
|
The SAJ Output Collector will retrieve the generation of each day of the current month and
|
41
46
|
push the data once to PVOutput.
|
42
|
-
Run the SAJ Output Collector in a screen or via init of some sort
|
43
47
|
|
44
|
-
|
48
|
+
Run the SAJ Output Collector from the command prompt or shell
|
45
49
|
|
46
|
-
|
47
|
-
a certain frequency.
|
50
|
+
saj_output_collector
|
48
51
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
+
## Scheduling the collecor
|
53
|
+
|
54
|
+
On Linux you can add ``saj_collector`` and ``saj_output_collector`` to your crontab to let it automatically push with
|
55
|
+
a certain frequency.
|
52
56
|
|
53
57
|
At the moment you add any of these to your crontab you have to make sure
|
54
58
|
that the ``saj_collector.yaml`` file can be found. For example when you put the ``saj_collector.yaml`` file
|
@@ -57,13 +61,16 @@ add to your crontab
|
|
57
61
|
|
58
62
|
*/5 6-21 * * * cd /usr/local/bin && ruby /usr/local/bin/saj_collector
|
59
63
|
|
64
|
+
On Windows you can create a task using the Task Scheduler. Make sure that for the Action you specific the path
|
65
|
+
of the ``saj_collector.yaml`` file as ``Start in``.
|
66
|
+
|
60
67
|
## Development
|
61
68
|
|
62
69
|
After checking out the repo, run `bin/setup` to install dependencies.
|
63
70
|
|
64
71
|
To install this gem onto your local machine, run `bundle exec rake install`. To
|
65
72
|
release a new version, update the version number
|
66
|
-
in `version.rb`, and then run `bundle exec rake release`, which
|
73
|
+
in `lib/saj_collector/version.rb`, and then run `bundle exec rake release`, which
|
67
74
|
will create a git tag for the version, push git commits and tags,
|
68
75
|
and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
69
76
|
|
data/exe/saj_collector
CHANGED
@@ -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(
|
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
|
data/exe/saj_output_collector
CHANGED
@@ -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(
|
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
|
-
|
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)
|
data/saj_collector.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
lib = File.expand_path('
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
require 'saj_collector/version'
|
4
4
|
|
@@ -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 'ipaddress'
|
20
21
|
spec.add_dependency 'pvoutput', '~> 0.4.0'
|
21
22
|
|
22
23
|
spec.add_development_dependency 'bundler'
|
23
|
-
spec.add_development_dependency 'rake', '
|
24
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
24
25
|
spec.add_development_dependency 'rspec'
|
25
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
26
|
+
spec.add_development_dependency 'rubocop', '~> 0.52.0'
|
26
27
|
spec.add_development_dependency 'rubocop-rspec'
|
27
28
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saj_collector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johnny Willemsen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-19 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
|
@@ -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:
|
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:
|
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.
|
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.
|
96
|
+
version: 0.52.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rubocop-rspec
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,6 +117,7 @@ executables:
|
|
103
117
|
extensions: []
|
104
118
|
extra_rdoc_files: []
|
105
119
|
files:
|
120
|
+
- ".github/FUNDING.yml"
|
106
121
|
- ".github/workflows/ruby.yml"
|
107
122
|
- ".rubocop.yml"
|
108
123
|
- ".travis.yml"
|
@@ -137,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
152
|
- !ruby/object:Gem::Version
|
138
153
|
version: '0'
|
139
154
|
requirements: []
|
140
|
-
rubygems_version: 3.0.
|
155
|
+
rubygems_version: 3.0.8
|
141
156
|
signing_key:
|
142
157
|
specification_version: 4
|
143
158
|
summary: Pull stats from SAJ Solar Inverter and push them to PVOutput
|