saj_collector 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6539a7bc0a1c18db6461405bf2c6a304aa01f23c
4
+ data.tar.gz: 2b0fbc3ff726288947e0dc1bbe1252bcd050ca6b
5
+ SHA512:
6
+ metadata.gz: e865e4bfdfb131960fd742e8262243fe031f3858285f25dd7ae4d8fa97ba8539c82fdabcf32314597df3e4e01e5b9621b3b252f1a16659bb3ec31dae08f588e4
7
+ data.tar.gz: f795f23be35fd57d38254a790840ea83484804fc7d439c84fa08e2aae5439d3dce78edd5682347bbf7ea478898c1d0701b187b7271f0f9b100432436b50b65de
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behaviour by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behaviour may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 John Ferlito
4
+ Copyright (c) 2016 Johnny Willemsen
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # SAJ Collector
2
+
3
+ Pull stats from SAJ Solar Inverter and push them to PVOutput. This
4
+ ruby gem is based on https://github.com/johnf/jfy_collector
5
+
6
+ ## Installation
7
+
8
+ Install it:
9
+
10
+ $ gem install saj_collector
11
+
12
+ ## Usage
13
+
14
+ Create a config file for PVOutput in ```/etc/saj_collector/saj_collector.yaml```.
15
+ This should contain the IP address of your SAJ Solar Invertor, and your
16
+ PVOutput system id and API key
17
+
18
+ ``` yaml
19
+ ---
20
+ :saj: a.b.c.d
21
+ :system_id: 123456
22
+ :api_key: fb6a2e3
23
+ ```
24
+
25
+ Run the SAJ Collector in a screen or via init of some sort
26
+
27
+ $ saj_collector
28
+
29
+ ## Development
30
+
31
+ After checking out the repo, run `bin/setup` to install dependencies.
32
+ Then, run `rake rspec` to run the tests. You can also
33
+ run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ To install this gem onto your local machine, run `bundle exec rake install`. To
36
+ release a new version, update the version number
37
+ in `version.rb`, and then run `bundle exec rake release`, which
38
+ will create a git tag for the version, push git commits and tags,
39
+ and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jwillemsen/saj_collector.
44
+ This project is intended to be a safe, welcoming space for
45
+ collaboration, and contributors are expected to adhere
46
+ to the [Contributor Covenant](contributor-covenant.org) code of conduct.
47
+
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms
52
+ of the [MIT License](http://opensource.org/licenses/MIT).
53
+
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rubocop/rake_task'
3
+
4
+ RuboCop::RakeTask.new
data/bin/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail
4
+ IFS=$'\n\t'
5
+
6
+ bundle install
data/circle.yml ADDED
@@ -0,0 +1,6 @@
1
+ test:
2
+ post:
3
+ - bundle exec rubocop
4
+ machine:
5
+ ruby:
6
+ version: 2.2.3
data/exe/saj_collector ADDED
@@ -0,0 +1,96 @@
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
+ options = {
16
+ 'temperature' => 0, # Temperature in celcius
17
+ 'energy_generated' => 0, # Energy generation in watt hours
18
+ 'power_generated' => 0, # Power generation in watts
19
+ 'voltage' => 0, # Voltage in volts
20
+ 'amperage' => 0, # Amperage
21
+ 'power_today' => 0,
22
+ 'power_all_time' => 0,
23
+ 'runtime_today' => 0,
24
+ 'runtime_all_time' => 0
25
+ }
26
+
27
+ loop do
28
+ # Get the current realtime data from the SAJ device
29
+ c = Net::HTTP.get(sajcollector_config[:saj], '/real_time_data.xml')
30
+
31
+ # Let REXML parse the XML site
32
+ doc = REXML::Document.new c
33
+
34
+ # Get the temperature
35
+ doc.elements.each("real_time_data/temp"){
36
+ |e| options[:temperature] = e.text
37
+ }
38
+
39
+ # e-today is in kWh where pvoutput is Wh
40
+ doc.elements.each("real_time_data/e-today"){
41
+ |e| options[:energy_generated] = e.text.to_f * 1000
42
+ }
43
+
44
+ # Get the power generated
45
+ doc.elements.each("real_time_data/p-ac"){
46
+ |e| options[:power_generated] = e.text
47
+ }
48
+
49
+ # Get the current amperage
50
+ doc.elements.each("real_time_data/i-grid"){
51
+ |e| options[:amperage] = e.text
52
+ }
53
+
54
+ # Get the voltage
55
+ doc.elements.each("real_time_data/v-grid"){
56
+ |e| options[:voltage] = e.text
57
+ }
58
+ doc.elements.each("real_time_data/e-today"){
59
+ |e| options[:power_today] = e.text
60
+ }
61
+ doc.elements.each("real_time_data/e-total"){
62
+ |e| options[:power_all_time] = e.text
63
+ }
64
+ doc.elements.each("real_time_data/t-today"){
65
+ |e| options[:runtime_today] = e.text
66
+ }
67
+ doc.elements.each("real_time_data/t-total"){
68
+ |e| options[:runtime_all_time] = e.text
69
+ }
70
+
71
+ puts
72
+ puts '-------------------------'
73
+ puts
74
+ puts "Time: #{Time.now}"
75
+ puts
76
+ puts 'Realtime:'
77
+ puts " Temp: #{options[:temperature]} C"
78
+ puts " V: #{options[:voltage]} V"
79
+ puts " I: #{options[:amperage]} A"
80
+ puts " P: #{options[:power_generated]} W"
81
+ puts
82
+ puts 'Total:'
83
+ puts " Power (today): #{options[:power_today]} kWH"
84
+ puts " Power (all time): #{options[:power_all_time]} kWH"
85
+ puts " Run Time: #{options[:runtime_today]} Hours"
86
+ puts " Run Time: #{options[:runtime_all_time]} Hours"
87
+ puts
88
+
89
+ pvoutput.add_status(
90
+ :energy_generated => options[:energy_generated],
91
+ :power_generated => options[:power_generated],
92
+ :temperature => options[:temperature],
93
+ :voltage => options[:voltage],
94
+ )
95
+ sleep(60 * 5)
96
+ end
@@ -0,0 +1,3 @@
1
+ module SAJCollector
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ require 'saj_collector/version'
2
+
3
+ module SAJCollector
4
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'saj_collector/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'saj_collector'
8
+ spec.version = SAJCollector::VERSION
9
+ spec.authors = ['Johnny Willemsen']
10
+ spec.email = ['jwillemsen@remedy.nl']
11
+
12
+ spec.summary = 'Pull stats from SAJ Solar Inverter and push them to PVOutput'
13
+ spec.homepage = 'https://github.com/jwillemsen/saj_collector'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.require_paths = ['lib']
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+
21
+ spec.add_dependency 'net'
22
+ spec.add_dependency 'pvoutput'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.10'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rubocop'
27
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: saj_collector
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Johnny Willemsen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-02-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: net
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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pvoutput
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - jwillemsen@remedy.nl
86
+ executables:
87
+ - saj_collector
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - CODE_OF_CONDUCT.md
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - bin/setup
97
+ - circle.yml
98
+ - exe/saj_collector
99
+ - lib/saj_collector/version.rb
100
+ - lib/say_collector.rb
101
+ - saj_collector.gemspec
102
+ homepage: https://github.com/jwillemsen/saj_collector
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.4.5
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Pull stats from SAJ Solar Inverter and push them to PVOutput
126
+ test_files: []