saj_collector 0.5.7 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 142b2785eb3f49663f7e3c58cbb68e5396cbab7851725d5c2b50c1be75ca6bf4
4
- data.tar.gz: 520737a4c49879ef23781f4cac71dfa9652cd6602953f2dff913e270d1647cad
3
+ metadata.gz: a85c0d0e7e941a3f6089fa7714f85ba53d1497f8a2c04b000497c9cf0b20fe35
4
+ data.tar.gz: c949ccb9562e0dca93a1b6ff5826b5e1df4fc9ee2208d9d253df1c5cb448dbf7
5
5
  SHA512:
6
- metadata.gz: 3b03aaa0f7c6907c5d0d6cebcae134e00c145e33e760c53693d551dc35823f1a9b61149eabdc8534e051906d8d0fc2f5ac488328d459847e6f5dfea65ab2835b
7
- data.tar.gz: 02ea3bc2079243b2ccfb217381158d0a049d4332e80afc5c37176c7d6b69ea774bf899177336a60b92339e4143131d104500f733ce3dfd5d8b9698400e21ff40
6
+ metadata.gz: 693cdb0965d8e6c62705e5b793f85e09e569435cfb0df3e4bb1112b4b67f2b828dcec66cf58b9c1397e4a7a7450d332cbd2778c985766ca2019b341325a44d08
7
+ data.tar.gz: 56a40d75b2272e38da1983c55b1488ecf1da96f98c863ef9885d5730b08a92a79523bf36ddd99393ae45a44177cf99a4b974a8302064a3900facd5532ea373a8
@@ -0,0 +1,12 @@
1
+ # Set update schedule for GitHub Actions
2
+ version: 2
3
+ updates:
4
+ - package-ecosystem: "github-actions"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "weekly"
8
+
9
+ - package-ecosystem: bundler
10
+ directory: "/"
11
+ schedule:
12
+ interval: weekly
@@ -1,4 +1,4 @@
1
- name: Ruby
1
+ name: ruby
2
2
 
3
3
  on:
4
4
  push:
@@ -6,36 +6,26 @@ on:
6
6
  branches:
7
7
  - master
8
8
  schedule:
9
- - cron: '0 7 * * SUN'
9
+ - cron: '0 1 * * SUN'
10
10
 
11
11
  jobs:
12
12
  build:
13
13
  runs-on: ubuntu-latest
14
14
  strategy:
15
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
16
+ ruby-version: [ '2.5', '2.6', '2.7', '3.0', 'ruby-head' ]
17
+ name: ruby ${{ matrix.ruby-version }}
31
18
  steps:
32
- - uses: actions/checkout@v1
33
- - name: Set up Ruby 2.6
34
- uses: actions/setup-ruby@v1
19
+ - uses: actions/checkout@v2
20
+ - uses: ruby/setup-ruby@v1
35
21
  with:
36
- ruby-version: ${{ matrix.RubyVersion }}
37
- - name: Build and test with Rake
38
- run: |
39
- gem install bundler
40
- bundle install --jobs 4 --retry 3
41
- bundle exec rake
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ bundler-cache: true
24
+ - name: Install dependencies
25
+ run: bundle install
26
+ - name: Lint files
27
+ run: bundle exec rubocop
28
+ - name: Test with Rake
29
+ run: bundle exec rake
30
+
31
+
data/.rubocop.yml CHANGED
@@ -1,3 +1,8 @@
1
- Metrics/LineLength:
1
+ AllCops:
2
+ NewCops: enable
3
+
4
+ Layout/LineLength:
2
5
  Max: 120
3
6
 
7
+ Layout/HashAlignment:
8
+ EnforcedColonStyle: table
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
data/README.md CHANGED
@@ -1,17 +1,17 @@
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://rubygems.org/gems/saj_collector)
6
6
 
7
- Pull stats from SAJ Solar Inverter and push them to PVOutput. This
7
+ Pull statistics from [SAJ Solar Inverter](https://www.saj-electric.com/) and push them to [PVOutput](https://pvoutput.org/). This
8
8
  ruby gem is based on https://github.com/johnf/jfy_collector
9
9
 
10
10
  ## Installation
11
11
 
12
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).
13
13
 
14
- Install it by running the following command from a linux shell or windows command prompt
14
+ Install saj_collector by running the following command from a linux shell or windows command prompt
15
15
 
16
16
  gem install saj_collector
17
17
 
@@ -25,7 +25,8 @@ system id and API key can be found on your
25
25
 
26
26
  Some SAJ Solar Inverters provide the generation of each day with a granularity of 0.1kWh and some with
27
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.
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.
29
30
 
30
31
  ``` yaml
31
32
  :saj: a.b.c.d
@@ -39,16 +40,14 @@ Run the SAJ Collector from the command prompt or shell
39
40
  saj_collector
40
41
 
41
42
  This will run the current power generation frm the SAJ Collector and push the
42
- data once to PVOutput.
43
+ data to PVOutput.
43
44
 
44
45
  The SAJ Output Collector will retrieve the generation of each day of the current month and
45
- push the data once to PVOutput.
46
-
47
- Run the SAJ Output Collector from the command prompt or shell
46
+ push the data to PVOutput. Run the SAJ Output Collector from the command prompt or shell
48
47
 
49
48
  saj_output_collector
50
49
 
51
- ## Scheduling the collecor
50
+ ## Scheduling the collector
52
51
 
53
52
  On Linux you can add ``saj_collector`` and ``saj_output_collector`` to your crontab to let it automatically push with
54
53
  a certain frequency.
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
  require 'rubocop/rake_task'
data/exe/saj_collector CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'rexml/document'
4
5
  require 'net/http'
@@ -16,22 +17,22 @@ sajcollector_config = YAML.load_file(yaml_file)
16
17
  pvoutput = PVOutput::Client.new(sajcollector_config[:system_id], sajcollector_config[:api_key])
17
18
 
18
19
  unless IPAddress.valid?(sajcollector_config[:saj])
19
- raise ("[#{sajcollector_config[:saj]}] is not a valid IP address, please correct your #{yaml_file} file")
20
+ raise("[#{sajcollector_config[:saj]}] is not a valid IP address, please correct your #{yaml_file} file")
20
21
  end
21
22
 
22
23
  # Get the current realtime data from the SAJ device
23
24
  c = Net::HTTP.get(sajcollector_config[:saj], '/real_time_data.xml')
24
25
 
25
26
  options = {
26
- 'temperature' => 0, # Temperature in celcius
27
- 'energy_generated' => 0, # Energy generation in watt hours
28
- 'power_generated' => 0, # Power generation in watts
29
- 'voltage' => 0, # Voltage in volts
30
- 'amperage' => 0, # Amperage
31
- 'power_today' => 0,
32
- 'power_all_time' => 0,
33
- 'runtime_today' => 0,
34
- 'runtime_all_time' => 0
27
+ temperature: 0, # Temperature in celcius
28
+ energy_generated: 0, # Energy generation in watt hours
29
+ power_generated: 0, # Power generation in watts
30
+ voltage: 0, # Voltage in volts
31
+ amperage: 0, # Amperage
32
+ power_today: 0,
33
+ power_all_time: 0,
34
+ runtime_today: 0,
35
+ runtime_all_time: 0
35
36
  }
36
37
 
37
38
  # Let REXML parse the XML site
@@ -96,7 +97,7 @@ puts " Run Time: #{options[:runtime_all_time]} Hours"
96
97
 
97
98
  pvoutput.add_status(
98
99
  energy_generated: options[:energy_generated],
99
- power_generated: options[:power_generated],
100
- temperature: options[:temperature],
101
- voltage: options[:voltage]
100
+ power_generated: options[:power_generated],
101
+ temperature: options[:temperature],
102
+ voltage: options[:voltage]
102
103
  )
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'rexml/document'
4
5
  require 'net/http'
@@ -16,7 +17,7 @@ sajcollector_config = YAML.load_file(yaml_file)
16
17
  pvoutput = PVOutput::Client.new(sajcollector_config[:system_id], sajcollector_config[:api_key])
17
18
 
18
19
  unless IPAddress.valid?(sajcollector_config[:saj])
19
- raise ("[#{sajcollector_config[:saj]}] is not a valid IP address, please correct your #{yaml_file} file")
20
+ raise("[#{sajcollector_config[:saj]}] is not a valid IP address, please correct your #{yaml_file} file")
20
21
  end
21
22
 
22
23
  # Get the current day trend data from the SAJ device
@@ -36,7 +37,7 @@ options = {
36
37
  }
37
38
 
38
39
  counter = 0
39
- current_day = '00'
40
+ current_day = 1
40
41
  day_trend_multiplication = 100
41
42
 
42
43
  # Some SAJ Inverters provide they energy_generated in granularity of 0.1kWh and
@@ -53,13 +54,14 @@ while counter < days
53
54
  doc.elements.each("day_trend/d#{counter}") do |e|
54
55
  value[:energy_generated] = (e.text.to_i * day_trend_multiplication).to_s
55
56
  end
56
- options[:"#{m}#{current_day.next!}"] = value
57
-
57
+ options[:"#{m}#{current_day.to_s.rjust(2, '0')}"] = value
58
58
  counter += 1
59
+ current_day += 1
59
60
  end
60
61
 
61
62
  options.each do |date, values|
62
- puts "Energy generated #{date}: #{values[:energy_generated]} Wh"
63
+ energy_generated = values[:energy_generated].to_i / 1000.0
64
+ puts "Energy generated #{date}: #{energy_generated} kWh"
63
65
  end
64
66
 
65
67
  pvoutput.add_batch_output(options)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SAJCollector
2
- VERSION = '0.5.7'.freeze
4
+ VERSION = '1.0.3'
3
5
  end
data/lib/say_collector.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'saj_collector/version'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'saj_collector/version'
@@ -8,7 +10,7 @@ Gem::Specification.new do |spec|
8
10
  spec.authors = ['Johnny Willemsen']
9
11
  spec.email = ['jwillemsen@remedy.nl']
10
12
 
11
- spec.summary = 'Pull stats from SAJ Solar Inverter and push them to PVOutput'
13
+ spec.summary = 'Pull statistics from SAJ Solar Inverter and push them to PVOutput'
12
14
  spec.homepage = 'https://github.com/jwillemsen/saj_collector'
13
15
  spec.license = 'MIT'
14
16
 
@@ -17,12 +19,14 @@ Gem::Specification.new do |spec|
17
19
  spec.require_paths = ['lib']
18
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
21
 
22
+ spec.required_ruby_version = '>= 2.5'
23
+
20
24
  spec.add_dependency 'ipaddress'
21
- spec.add_dependency 'pvoutput', '~> 0.4.0'
25
+ spec.add_dependency 'pvoutput', '>= 1.0'
22
26
 
23
27
  spec.add_development_dependency 'bundler'
24
28
  spec.add_development_dependency 'rake', '>= 12.3.3'
25
29
  spec.add_development_dependency 'rspec'
26
- spec.add_development_dependency 'rubocop', '~> 0.52.0'
30
+ spec.add_development_dependency 'rubocop', '~> 1.12.0'
27
31
  spec.add_development_dependency 'rubocop-rspec'
28
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saj_collector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 1.0.3
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-05-20 00:00:00.000000000 Z
11
+ date: 2021-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ipaddress
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: pvoutput
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.4.0
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.4.0
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.52.0
89
+ version: 1.12.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.52.0
96
+ version: 1.12.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop-rspec
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -108,7 +108,7 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- description:
111
+ description:
112
112
  email:
113
113
  - jwillemsen@remedy.nl
114
114
  executables:
@@ -118,16 +118,15 @@ extensions: []
118
118
  extra_rdoc_files: []
119
119
  files:
120
120
  - ".github/FUNDING.yml"
121
+ - ".github/dependabot.yml"
121
122
  - ".github/workflows/ruby.yml"
122
123
  - ".rubocop.yml"
123
- - ".travis.yml"
124
124
  - CODE_OF_CONDUCT.md
125
125
  - Gemfile
126
126
  - LICENSE.txt
127
127
  - README.md
128
128
  - Rakefile
129
129
  - bin/setup
130
- - circle.yml
131
130
  - exe/saj_collector
132
131
  - exe/saj_output_collector
133
132
  - lib/saj_collector/version.rb
@@ -137,7 +136,7 @@ homepage: https://github.com/jwillemsen/saj_collector
137
136
  licenses:
138
137
  - MIT
139
138
  metadata: {}
140
- post_install_message:
139
+ post_install_message:
141
140
  rdoc_options: []
142
141
  require_paths:
143
142
  - lib
@@ -145,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
144
  requirements:
146
145
  - - ">="
147
146
  - !ruby/object:Gem::Version
148
- version: '0'
147
+ version: '2.5'
149
148
  required_rubygems_version: !ruby/object:Gem::Requirement
150
149
  requirements:
151
150
  - - ">="
@@ -153,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
152
  version: '0'
154
153
  requirements: []
155
154
  rubygems_version: 3.0.8
156
- signing_key:
155
+ signing_key:
157
156
  specification_version: 4
158
- summary: Pull stats from SAJ Solar Inverter and push them to PVOutput
157
+ summary: Pull statistics from SAJ Solar Inverter and push them to PVOutput
159
158
  test_files: []
data/.travis.yml DELETED
@@ -1,35 +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
- - 2.7
12
- - ruby-head
13
- gemfile:
14
- - Gemfile
15
- matrix:
16
- allow_failures:
17
- - rvm: ruby-head
18
- env:
19
- matrix:
20
- - CODECLIMATE_REPO_TOKEN=2b46019558c79326fc3cc87f2e4261610256aee236063c4b62b8ed8d2c2ce21d
21
- global:
22
- secure: pIBdjy8REKRp9GPVeR22JYu0GrCmS2d1rz7Yyxo9lV7yMKUQK2lQw5PQ1fQizxK1NryiNx5nrYJol/EC9a/MTp8rGAOVwEYv5C7gO/Ede/ADuOo7OUjCvI+a88hWNQqp04cZAeYLaX0Avdz/odbkXKHAH8HTt028f1REMKXH3CUm7CmqTEPlB96xXk8nSH8IAQZZlSw1Yu2bIP18h4m73USh9JM/nZbfY7lz2jCxLeinFFJl3ELkfAtvuuo6ptyuu7uZTpZd/9H6N0ddEFUFUcimZbXCcF21S3BdTX6eSyB1h66q17Tx6fi7/rQh+Jah8yhOrgjr+LLZoIAXosgBt/LnfN2V1MqJVqd/ajN9TBVp+mB/NV7z+nqcUNSEbleOpE9tTb4DHa3izA2cL17wuA0sxxNuvaUVbu1u4iFQNfEtiVmCdqZwAp9cXeD0x1RSLWUofn413xAzQBNiH/UxXwVFvZzUwtrlkzEUyYWtprm9RWyJEaEr1a4Tv5LhjmeaB2e9gwDzIT/RZaTfTswZzpbBsN3/dOeLhZkH4hCbN7Um2OBymQlVTNpZp/jRM/pEepMUdJjQ2SUU26/9B5Xqp3M01zUr2Z65djmyAkK3DkdLAzGo9FdWZW7VdDKLaO17TeDWizkQLD9pZUr1QfniYJzUxqYb7oqfekhtcDCMOag=
23
- addons:
24
- code_climate:
25
- repo_token: 2b46019558c79326fc3cc87f2e4261610256aee236063c4b62b8ed8d2c2ce21d
26
- after_success:
27
- - bundle exec codeclimate-test-reporter
28
- deploy:
29
- provider: rubygems
30
- api_key:
31
- secure: YnibTFYFBn8XvyocId6wfKm3qCrVOprorIkKHEok4g8AOo3VHea9YxChmp2E/yvVqDdT9G7yKg3hn+JwuolYOIyGVSlS7AXOHguzHLcOI7iYwAd+RWFXDmn1MMFIX/tVV0oeRu8mNGbxNIbofI6DtExH0RHRHN0FTIqxPzH8Se0TbkHzznKkouwu55CU8ss7kh/CYPeFJOEyfCxZ+NNm1cdWocNkMbhPxT2FgsXGRlIMsABc/UpTMUR2mtmGqFUiwnIKvxkhI9qUEePfqHYU/IVGubwUjSE5LJRvOtAOdglj4QH4UZKlI2TJI6kq4a/1q7lZuAnONyqdlROrmBIjm9K9g9l0XvCBeReNpZoXRxIS+78F0H1GSCvxajaRfJYk0Po4RZ6JE2N8hhxSpqyMRHy2mVQiu5fBMXaZXcH7buIgiPY7KH+JFBgyGUqFR8a+8d0kKuX0Fz/sM1YmO2iATtP+CXqSotDWmU4nn8dMoEyvzvHlG5O49ZIlhG+ze6SlryWOlgiewEk8Gf+Nn3q5En1jgxAZTSPy5eyzQdT4RR4dysMy8p1BGCxIXyaKDDZVtk3n+00kG4VMLmrLehfrjalNY6NDAkOEO5Fc1OrQEYXKT/CHlA3R7iaZDqsblRgfpEDYTsXAffMobyggnrrWZRxrJppvITGCFOb6FFvYjKI=
32
- gemspec: saj_collector.gemspec
33
- on:
34
- tags: true
35
- 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