jfy_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: 6f934d450887c81f308f8ae7478f5ea469a8eb13
4
+ data.tar.gz: b99ef2859a3b7ca833a1e86871c8084be6ee5068
5
+ SHA512:
6
+ metadata.gz: d8ac58e8120dd4e4dea896f91f4ffe0c3f27f162c35122df16304da80d974e981a3f3166138674974b159853d5d845167c854cb823866dbaa99fef60f01152ef
7
+ data.tar.gz: bb3e33b41e0394957202c0684c17ca95fb7e7a526dbf6bb5ee552d2d7d64339e7425af095d6d41f8b966b4ac7d8ddb3d0fbd712b63b34732bf0d3fa9094ae17d
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ /.bundle/
2
+ /Gemfile.lock
3
+ /coverage/
4
+ /pkg/
5
+ /spec/reports/
6
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,22 @@
1
+ require: rubocop-rspec
2
+
3
+ HashSyntax:
4
+ EnforcedStyle: hash_rockets
5
+
6
+ Style/Documentation:
7
+ Enabled: false
8
+
9
+ Style/Lambda:
10
+ Enabled: false
11
+
12
+ Style/TrailingComma:
13
+ EnforcedStyleForMultiline: comma
14
+
15
+ Metrics/LineLength:
16
+ Max: 120
17
+
18
+ Style/ModuleFunction:
19
+ Enabled: false
20
+
21
+ AlignHash:
22
+ EnforcedHashRocketStyle: table
@@ -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,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 John Ferlito
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # JFY Collector
2
+
3
+ Pull stats from JFY Solar Inverter and push them to PVOutput
4
+
5
+ ## Installation
6
+
7
+ Install it:
8
+
9
+ $ gem install pvoutput
10
+
11
+ ## Usage
12
+
13
+ Create a config file for PVOutput in ```/etc/jfy_collector/pvoutput.yaml```.
14
+
15
+ ``` yaml
16
+ ---
17
+ :system_id: 123456
18
+ :api_key: fb6a2e3
19
+ ```
20
+
21
+ Run the JFY Collector in a screen or via init of some sort
22
+
23
+ $ jfy_collector
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/johnf/jfy_collector. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
34
+
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
39
+
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/jfy_collector ADDED
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'jfy/client'
4
+ require 'pvoutput/client'
5
+ require 'awesome_print'
6
+ require 'yaml'
7
+
8
+ pvoutput_config = YAML.load_file('/etc/jfy_collector/pvoutput.yaml')
9
+
10
+ jfy = Jfy::Client.new
11
+
12
+ retries = 0
13
+
14
+ begin
15
+ puts 'Re Register'
16
+ jfy.re_register
17
+
18
+ puts 'Offine Query'
19
+ serial = jfy.offline_query
20
+ rescue BadPacket, ReadTimeout => e
21
+ puts "Bad Packet #{e} ... Retrying" if @debug
22
+ puts if @debug
23
+ retries += 1
24
+ exit if retries > 5
25
+ retry
26
+ end
27
+
28
+ serial_num = 0x02
29
+ jfy.register(serial, serial_num)
30
+
31
+ puts 'Inverter Info'
32
+ data = jfy.query_inverter_info(serial_num)
33
+ ap data
34
+
35
+ # puts 'Set Info'
36
+ # data = jfy.query_set_info(serial_num)
37
+ # ap data
38
+
39
+ pvoutput = PVOutput::Client.new(pvoutput_config[:system_id], pvoutput_config[:api_key])
40
+
41
+ loop do
42
+ data = jfy.query_normal_info(serial_num)
43
+
44
+ puts
45
+ puts '-------------------------'
46
+ puts
47
+ puts "Time: #{Time.now}"
48
+ puts
49
+ puts 'Realtime:'
50
+ puts " Temp: #{data[:temperature]} C"
51
+ puts " V: #{data[:voltage].join('/')} V"
52
+ puts " I: #{data[:current].join('/')} A"
53
+ puts " P: #{data[:power][:now]} W"
54
+ puts
55
+ puts 'Total:'
56
+ puts " Power (today): #{data[:power][:today]} kWH"
57
+ puts " Power (all time): #{data[:power][:total]} kWH"
58
+ puts " Run Time: #{data[:hours]} Hours"
59
+ puts
60
+
61
+ pvoutput.add_status(
62
+ :energy_generated => data[:power][:today],
63
+ :power_generated => data[:power][:now],
64
+ :temperature => data[:temperature],
65
+ :voltage => data[:voltage].first,
66
+ )
67
+
68
+ sleep(60 * 5)
69
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jfy_collector/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'jfy_collector'
8
+ spec.version = JfyCollector::VERSION
9
+ spec.authors = ['John Ferlito']
10
+ spec.email = ['johnf@inodes.org']
11
+
12
+ spec.summary = 'Pull stats from JFY Solar Inverter and push them to PVOutput'
13
+ spec.homepage = 'https://github.com/johnf/jfy_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 'jfy'
22
+ spec.add_dependency 'pvoutput'
23
+ spec.add_dependency 'awesome_print'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.10'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rubocop'
28
+ end
@@ -0,0 +1,4 @@
1
+ require 'jfy_collector/version'
2
+
3
+ module JfyCollector
4
+ end
@@ -0,0 +1,3 @@
1
+ module JfyCollector
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jfy_collector
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - John Ferlito
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-11-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jfy
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: awesome_print
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email:
99
+ - johnf@inodes.org
100
+ executables:
101
+ - jfy_collector
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rubocop.yml"
107
+ - CODE_OF_CONDUCT.md
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - bin/setup
113
+ - circle.yml
114
+ - exe/jfy_collector
115
+ - jfy_collector.gemspec
116
+ - lib/jfy_collector.rb
117
+ - lib/jfy_collector/version.rb
118
+ homepage: https://github.com/johnf/jfy_collector
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.4.5.1
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Pull stats from JFY Solar Inverter and push them to PVOutput
142
+ test_files: []