saj_collector 0.5.8 → 1.1.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: a0e32b86391108e73fe14c279167f59b95a62b212ebd26ba385009b6f6910c6a
4
- data.tar.gz: fdb0b4bcfa18d5f3643811db8c5638f65f08718b7a6a69ba6447239a74878eb2
3
+ metadata.gz: ae108321dc9e1f55fea4d48b1ced7e3826be98080f31a8ac627f7fc588557817
4
+ data.tar.gz: 84ece89568d9be1b998553c66e4c53c1868fda90deaaf411657e9526c09ea4ff
5
5
  SHA512:
6
- metadata.gz: f575fb51be5d5d9c8f24630d90799fc6062e8be9313c0a31a2c35906bfc30c1004d0c5c8a4b03cebc5fb392e5b2a270f597aeaae36d14e4050cb843f2504dcc3
7
- data.tar.gz: '06391f6189aeea508e877614541fc82f44308f0ef35be781a7c2edfb600ba909b7c8413a9ec2ee0a2f41faca01c5e36e65f86101e9ce52bdcdefca1b845ac897'
6
+ metadata.gz: 63329b7e06f371e12ce88f09deb1b6ccd5d3eef3a570b144806fdeeffe7ad2efc26381f38cfd445ff61c3c65c2c3b6e699fc243c53ab0b29652a4c3338454c65
7
+ data.tar.gz: 0bbc0b1a77849ae0c652b9cdc00371fe0fe224741ae42b10882ae5d8bae5e8036e43dcc8e7c3d159075130a0b7732ecb051180ddb51fc41bc76549953234a29f
@@ -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
 
@@ -28,11 +28,15 @@ a granularity of 0.01kWh. In case of the last you have to change the ```day_tren
28
28
  within your ```saj_collector.yaml``` to 10. An incorrect ```day_trend_multiplication_factor``` triggers
29
29
  a `Bad Post` exception when running the `saj_output_collector` script.
30
30
 
31
+ At the moment you are a [PVOutput donator](https://pvoutput.org/donate.jsp) change ```donation_mode``` to
32
+ true to enable the donation features of PVOutput.
33
+
31
34
  ``` yaml
32
35
  :saj: a.b.c.d
33
36
  :system_id: 123456
34
37
  :api_key: fb6a2e3
35
38
  :day_trend_multiplication_factor: 100
39
+ :donation_mode: false
36
40
  ```
37
41
 
38
42
  Run the SAJ Collector from the command prompt or shell
@@ -40,16 +44,14 @@ Run the SAJ Collector from the command prompt or shell
40
44
  saj_collector
41
45
 
42
46
  This will run the current power generation frm the SAJ Collector and push the
43
- data once to PVOutput.
47
+ data to PVOutput.
44
48
 
45
49
  The SAJ Output Collector will retrieve the generation of each day of the current month and
46
- push the data once to PVOutput.
47
-
48
- Run the SAJ Output Collector from the command prompt or shell
50
+ push the data to PVOutput. Run the SAJ Output Collector from the command prompt or shell
49
51
 
50
52
  saj_output_collector
51
53
 
52
- ## Scheduling the collecor
54
+ ## Scheduling the collector
53
55
 
54
56
  On Linux you can add ``saj_collector`` and ``saj_output_collector`` to your crontab to let it automatically push with
55
57
  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'
@@ -12,26 +13,29 @@ yaml_file = 'saj_collector.yaml'
12
13
  sajcollector_config = YAML.load_file(yaml_file)
13
14
 
14
15
  # Create a pvoutput with the configured system_id and api_key which both
15
- # can be obtained from the pvoutput website
16
- pvoutput = PVOutput::Client.new(sajcollector_config[:system_id], sajcollector_config[:api_key])
16
+ # can be obtained from the pvoutput website. At the moment donation_mode
17
+ # has been specified batching can be used
18
+ pvoutput = PVOutput::Client.new(
19
+ sajcollector_config[:system_id], sajcollector_config[:api_key], sajcollector_config[:donation_mode]
20
+ )
17
21
 
18
22
  unless IPAddress.valid?(sajcollector_config[:saj])
19
- raise ("[#{sajcollector_config[:saj]}] is not a valid IP address, please correct your #{yaml_file} file")
23
+ raise("[#{sajcollector_config[:saj]}] is not a valid IP address, please correct your #{yaml_file} file")
20
24
  end
21
25
 
22
26
  # Get the current realtime data from the SAJ device
23
27
  c = Net::HTTP.get(sajcollector_config[:saj], '/real_time_data.xml')
24
28
 
25
29
  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
30
+ temperature: 0, # Temperature in celcius
31
+ energy_generated: 0, # Energy generation in watt hours
32
+ power_generated: 0, # Power generation in watts
33
+ voltage: 0, # Voltage in volts
34
+ amperage: 0, # Amperage
35
+ power_today: 0,
36
+ power_all_time: 0,
37
+ runtime_today: 0,
38
+ runtime_all_time: 0
35
39
  }
36
40
 
37
41
  # Let REXML parse the XML site
@@ -96,7 +100,7 @@ puts " Run Time: #{options[:runtime_all_time]} Hours"
96
100
 
97
101
  pvoutput.add_status(
98
102
  energy_generated: options[:energy_generated],
99
- power_generated: options[:power_generated],
100
- temperature: options[:temperature],
101
- voltage: options[:voltage]
103
+ power_generated: options[:power_generated],
104
+ temperature: options[:temperature],
105
+ voltage: options[:voltage]
102
106
  )
@@ -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'
@@ -12,11 +13,14 @@ yaml_file = 'saj_collector.yaml'
12
13
  sajcollector_config = YAML.load_file(yaml_file)
13
14
 
14
15
  # Create a pvoutput with the configured system_id and api_key which both
15
- # can be obtained from the pvoutput website
16
- pvoutput = PVOutput::Client.new(sajcollector_config[:system_id], sajcollector_config[:api_key])
16
+ # can be obtained from the pvoutput website. At the moment donation_mode
17
+ # has been specified batching can be used
18
+ pvoutput = PVOutput::Client.new(
19
+ sajcollector_config[:system_id], sajcollector_config[:api_key], sajcollector_config[:donation_mode]
20
+ )
17
21
 
18
22
  unless IPAddress.valid?(sajcollector_config[:saj])
19
- raise ("[#{sajcollector_config[:saj]}] is not a valid IP address, please correct your #{yaml_file} file")
23
+ raise("[#{sajcollector_config[:saj]}] is not a valid IP address, please correct your #{yaml_file} file")
20
24
  end
21
25
 
22
26
  # Get the current day trend data from the SAJ device
@@ -36,7 +40,7 @@ options = {
36
40
  }
37
41
 
38
42
  counter = 0
39
- current_day = '00'
43
+ current_day = 1
40
44
  day_trend_multiplication = 100
41
45
 
42
46
  # Some SAJ Inverters provide they energy_generated in granularity of 0.1kWh and
@@ -53,13 +57,13 @@ while counter < days
53
57
  doc.elements.each("day_trend/d#{counter}") do |e|
54
58
  value[:energy_generated] = (e.text.to_i * day_trend_multiplication).to_s
55
59
  end
56
- options[:"#{m}#{current_day.next!}"] = value
57
-
60
+ options[:"#{m}#{current_day.to_s.rjust(2, '0')}"] = value
58
61
  counter += 1
62
+ current_day += 1
59
63
  end
60
64
 
61
65
  options.each do |date, values|
62
- energy_generated = values[:energy_generated].to_i/1000.0
66
+ energy_generated = values[:energy_generated].to_i / 1000.0
63
67
  puts "Energy generated #{date}: #{energy_generated} kWh"
64
68
  end
65
69
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SAJCollector
2
- VERSION = '0.5.8'.freeze
4
+ VERSION = '1.1.0'
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.18.2'
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.8
4
+ version: 1.1.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-08-19 00:00:00.000000000 Z
11
+ date: 2021-07-11 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.18.2
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.18.2
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,27 +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
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