senec 0.3.0 → 0.4.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: fafcc3312502159dab71fea097bf18148da6634d2c8207d6159e8edc5e44fe3e
4
- data.tar.gz: ccdd4146beb87d69ad400a2018126aefc468c542d1ee4955915ef3cfdd6fba11
3
+ metadata.gz: 7cc66f87a694b567a5d255e80aeca2ce5bd6bc31bbdce717f991c0f4a4bb6cae
4
+ data.tar.gz: 6c2def742896e62ee42d475983b4285ecb3e7a0a0315d6fc5317f959831d4401
5
5
  SHA512:
6
- metadata.gz: ffef52909f19a3ca27b341e0b3095c44ceece7799fb0e1839873451476a1cec559d41d0ed8bd3d07703019c8d74cbbcbf10b8875b79b3f747c7ec7a6a45551ba
7
- data.tar.gz: e20e6df0a012ee9e72cfb7eca37dc0c71ed25b42063d0c169f5797548d98340645b0162ba847c61208973b2b3fc0e7afdbd518e777e213815f34223e85786b27
6
+ metadata.gz: c1006a948b5e0932fd9c1e675dbaec90f11e5c6a54b5899c239db0854f7e8623c03030dff72f4162acd716e60ae256526ceea2e883bf7b8f3ac8220ad93fb049
7
+ data.tar.gz: 3004661d438142e41e30c758d41e9f0b7ecf3e2f74f5533387689c215aa92e11346806651f413c7b76cb686a575a8f0188f9e03829c38ae1ca36496f074f20f0
@@ -0,0 +1,23 @@
1
+ name: Continuous integration
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - name: Checkout the code
11
+ uses: actions/checkout@v2
12
+
13
+ - name: Set up Ruby
14
+ uses: ruby/setup-ruby@v1
15
+ with:
16
+ bundler-cache: true
17
+ ruby-version: '3.0'
18
+
19
+ - name: Lint with RuboCop
20
+ run: bundle exec rubocop
21
+
22
+ - name: Run tests
23
+ run: bundle exec rake
data/.rubocop.yml CHANGED
@@ -1,115 +1,17 @@
1
1
  require:
2
2
  - rubocop-performance
3
3
  - rubocop-rspec
4
+ - rubocop-rake
4
5
 
5
6
  AllCops:
6
- TargetRubyVersion: 2.5
7
- EnabledByDefault: true
8
-
9
- ### Metrics
10
-
11
- Metrics/MethodLength:
12
- Max: 20
13
-
14
- ### Bundler
15
-
16
- Bundler/OrderedGems:
17
- Enabled: false
18
-
19
- ### Style
20
-
21
- Style/FrozenStringLiteralComment:
22
- Enabled: false
23
-
24
- Style/SymbolArray:
25
- EnforcedStyle: brackets
26
-
27
- Style/MixinUsage:
28
- Enabled: false
7
+ TargetRubyVersion: 2.6
8
+ NewCops: enable
29
9
 
30
10
  Style/Documentation:
31
11
  Enabled: false
32
12
 
33
- Style/ClassAndModuleChildren:
34
- Enabled: false
35
-
36
- Style/Lambda:
37
- EnforcedStyle: literal
38
-
39
- Style/LambdaCall:
40
- Enabled: false
41
-
42
- Style/MethodCallWithArgsParentheses:
43
- Enabled: false
44
-
45
- Style/MissingElse:
46
- Enabled: false
47
-
48
- Style/Copyright:
49
- Enabled: false
50
-
51
- Style/InlineComment:
52
- Enabled: false
53
-
54
- Style/StringHashKeys:
55
- Enabled: false
56
-
57
- Style/MethodCalledOnDoEndBlock:
58
- Enabled: false
59
-
60
- Style/DocumentationMethod:
61
- Enabled: false
62
-
63
- Style/DisableCopsWithinSourceCodeDirective:
64
- Enabled: false
65
-
66
- Style/ConstantVisibility:
67
- Enabled: false
68
-
69
- ### Layout
70
-
71
- Layout/DotPosition:
72
- EnforcedStyle: trailing
73
-
74
- Layout/EndAlignment:
75
- EnforcedStyleAlignWith: variable
76
-
77
- Layout/SpaceInsideArrayLiteralBrackets:
78
- Enabled: false
79
-
80
- Layout/HashAlignment:
81
- Enabled: false
82
-
83
- Layout/MultilineMethodArgumentLineBreaks:
84
- Enabled: false
85
-
86
- Layout/MultilineArrayLineBreaks:
87
- Enabled: false
88
-
89
- Layout/MultilineAssignmentLayout:
90
- Enabled: false
91
-
92
- # RSpec
93
-
94
- RSpec/MultipleExpectations:
95
- Enabled: false
96
-
97
- RSpec/AlignRightLetBrace:
98
- Enabled: false
99
-
100
- RSpec/MultipleDescribes:
101
- Enabled: false
102
-
103
- RSpec/NestedGroups:
104
- Enabled: false
105
-
106
- RSpec/ImplicitSubject:
107
- Enabled: false
108
-
109
- # Lint
110
-
111
- Lint/ConstantResolution:
13
+ Style/FrozenStringLiteralComment:
112
14
  Enabled: false
113
15
 
114
- Lint/NumberConversion:
115
- Enabled: false
16
+ Metrics/MethodLength:
17
+ Max: 15
data/Gemfile CHANGED
@@ -9,11 +9,14 @@ gem 'rake'
9
9
  # rspec-3.10.0 (http://github.com/rspec)
10
10
  gem 'rspec'
11
11
 
12
- # Automatic Ruby code style checking tool. (https://github.com/rubocop-hq/rubocop)
12
+ # Automatic Ruby code style checking tool. (https://github.com/rubocop/rubocop)
13
13
  gem 'rubocop'
14
14
 
15
- # Automatic performance checking tool for Ruby code. (https://github.com/rubocop-hq/rubocop-performance)
15
+ # Automatic performance checking tool for Ruby code. (https://github.com/rubocop/rubocop-performance)
16
16
  gem 'rubocop-performance'
17
17
 
18
- # Code style checking for RSpec files (https://github.com/rubocop-hq/rubocop-rspec)
18
+ # Code style checking for RSpec files (https://github.com/rubocop/rubocop-rspec)
19
19
  gem 'rubocop-rspec'
20
+
21
+ # A RuboCop plugin for Rake (https://github.com/rubocop/rubocop-rake)
22
+ gem 'rubocop-rake'
data/README.md CHANGED
@@ -35,6 +35,7 @@ puts "Wallbox charge power: [ #{request.wallbox_charge_power.join(',')} ] W"
35
35
  puts "\n"
36
36
  puts "Grid power: #{request.grid_power} W"
37
37
  puts "Current state of the system: #{request.current_state}"
38
+ puts "Measure time: #{Time.at request.measure_time}"
38
39
 
39
40
  # Example result:
40
41
  #
@@ -50,6 +51,7 @@ puts "Current state of the system: #{request.current_state}"
50
51
  #
51
52
  # Grid power: 315 W
52
53
  # Current state of the system: CHARGE
54
+ # Measure time: 2021-10-06 17:50:22 +0200
53
55
  ```
54
56
 
55
57
  ## Development
@@ -60,7 +62,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
60
62
 
61
63
  ## Contributing
62
64
 
63
- Bug reports and pull requests are welcome on GitHub at https://github.com/ledermann/senec. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ledermann/senec/blob/master/CODE_OF_CONDUCT.md).
65
+ Bug reports and pull requests are welcome on GitHub at https://github.com/solectrus/senec. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/solectrus/senec/blob/master/CODE_OF_CONDUCT.md).
64
66
 
65
67
 
66
68
  ## License
@@ -69,4 +71,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
69
71
 
70
72
  ## Code of Conduct
71
73
 
72
- Everyone interacting in this project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ledermann/senec/blob/master/CODE_OF_CONDUCT.md).
74
+ Everyone interacting in this project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/solectrus/senec/blob/master/CODE_OF_CONDUCT.md).
@@ -1,16 +1,16 @@
1
1
  module Senec # rubocop:disable Metrics/ModuleLength
2
2
  # Taken from https://github.com/mchwalisz/pysenec
3
3
  STATE_NAMES = {
4
- 0 => 'INITIAL STATE',
5
- 1 => 'ERROR INVERTER COMMUNICATION',
6
- 2 => 'ERROR ELECTRICY METER',
7
- 3 => 'RIPPLE CONTROL RECEIVER',
8
- 4 => 'INITIAL CHARGE',
9
- 5 => 'MAINTENANCE CHARGE',
10
- 6 => 'MAINTENANCE READY',
11
- 7 => 'MAINTENANCE REQUIRED',
12
- 8 => 'MAN. SAFETY CHARGE',
13
- 9 => 'SAFETY CHARGE READY',
4
+ 0 => 'INITIAL STATE',
5
+ 1 => 'ERROR INVERTER COMMUNICATION',
6
+ 2 => 'ERROR ELECTRICY METER',
7
+ 3 => 'RIPPLE CONTROL RECEIVER',
8
+ 4 => 'INITIAL CHARGE',
9
+ 5 => 'MAINTENANCE CHARGE',
10
+ 6 => 'MAINTENANCE READY',
11
+ 7 => 'MAINTENANCE REQUIRED',
12
+ 8 => 'MAN. SAFETY CHARGE',
13
+ 9 => 'SAFETY CHARGE READY',
14
14
  10 => 'FULL CHARGE',
15
15
  11 => 'EQUALIZATION: CHARGE',
16
16
  12 => 'DESULFATATION: CHARGE',
@@ -97,37 +97,37 @@ module Senec # rubocop:disable Metrics/ModuleLength
97
97
 
98
98
  # Taken from https://gist.github.com/smashnet/82ad0b9d7f0ba2e5098e6649ba08f88a
99
99
  BASIC_REQUEST = {
100
- 'STATISTIC': {
101
- 'CURRENT_STATE': '', # Current state of the system (int, see SYSTEM_STATE_NAME)
102
- 'LIVE_BAT_CHARGE_MASTER': '', # Battery charge amount since installation (kWh)
103
- 'LIVE_BAT_DISCHARGE_MASTER': '', # Battery discharge amount since installation (kWh)
104
- 'LIVE_GRID_EXPORT': '', # Grid export amount since installation (kWh)
105
- 'LIVE_GRID_IMPORT': '', # Grid import amount since installation (kWh)
106
- 'LIVE_HOUSE_CONS': '', # House consumption since installation (kWh)
107
- 'LIVE_PV_GEN': '', # PV generated power since installation (kWh)
108
- 'MEASURE_TIME': '' # Unix timestamp for above values (ms)
100
+ STATISTIC: {
101
+ CURRENT_STATE: '', # Current state of the system (int, see SYSTEM_STATE_NAME)
102
+ LIVE_BAT_CHARGE_MASTER: '', # Battery charge amount since installation (kWh)
103
+ LIVE_BAT_DISCHARGE_MASTER: '', # Battery discharge amount since installation (kWh)
104
+ LIVE_GRID_EXPORT: '', # Grid export amount since installation (kWh)
105
+ LIVE_GRID_IMPORT: '', # Grid import amount since installation (kWh)
106
+ LIVE_HOUSE_CONS: '', # House consumption since installation (kWh)
107
+ LIVE_PV_GEN: '', # PV generated power since installation (kWh)
108
+ MEASURE_TIME: '' # Unix timestamp for above values (ms)
109
109
  },
110
- 'ENERGY': {
111
- 'GUI_BAT_DATA_CURRENT': '', # Battery charge current: negative if discharging, positiv if charging (A)
112
- 'GUI_BAT_DATA_FUEL_CHARGE': '', # Remaining battery (percent)
113
- 'GUI_BAT_DATA_POWER': '', # Battery charge power: negative if discharging, positiv if charging (W)
114
- 'GUI_BAT_DATA_VOLTAGE': '', # Battery voltage (V)
115
- 'GUI_GRID_POW': '', # Grid power: negative if exporting, positiv if importing (W)
116
- 'GUI_HOUSE_POW': '', # House power consumption (W)
117
- 'GUI_INVERTER_POWER': '', # PV production (W)
118
- 'STAT_HOURS_OF_OPERATION': '' # Appliance hours of operation
110
+ ENERGY: {
111
+ GUI_BAT_DATA_CURRENT: '', # Battery charge current: negative if discharging, positiv if charging (A)
112
+ GUI_BAT_DATA_FUEL_CHARGE: '', # Remaining battery (percent)
113
+ GUI_BAT_DATA_POWER: '', # Battery charge power: negative if discharging, positiv if charging (W)
114
+ GUI_BAT_DATA_VOLTAGE: '', # Battery voltage (V)
115
+ GUI_GRID_POW: '', # Grid power: negative if exporting, positiv if importing (W)
116
+ GUI_HOUSE_POW: '', # House power consumption (W)
117
+ GUI_INVERTER_POWER: '', # PV production (W)
118
+ STAT_HOURS_OF_OPERATION: '' # Appliance hours of operation
119
119
  },
120
- 'BMS': {
121
- 'CHARGED_ENERGY': '', # List: Charged energy per battery
122
- 'DISCHARGED_ENERGY': '', # List: Discharged energy per battery
123
- 'CYCLES': '' # List: Cycles per battery
120
+ BMS: {
121
+ CHARGED_ENERGY: '', # List: Charged energy per battery
122
+ DISCHARGED_ENERGY: '', # List: Discharged energy per battery
123
+ CYCLES: '' # List: Cycles per battery
124
124
  },
125
- 'PV1': {
126
- 'POWER_RATIO': '', # Grid export limit (percent)
127
- 'P_TOTAL': '' # ?
125
+ PV1: {
126
+ POWER_RATIO: '', # Grid export limit (percent)
127
+ P_TOTAL: '' # ?
128
128
  },
129
- 'WALLBOX': {
130
- 'APPARENT_CHARGING_POWER': ''
129
+ WALLBOX: {
130
+ APPARENT_CHARGING_POWER: ''
131
131
  }
132
132
  }.freeze
133
133
  end
data/lib/senec/request.rb CHANGED
@@ -57,6 +57,11 @@ module Senec
57
57
  STATE_NAMES[state]
58
58
  end
59
59
 
60
+ def measure_time
61
+ value = response.dig('STATISTIC', 'MEASURE_TIME')
62
+ Senec::Value.new(value).to_i
63
+ end
64
+
60
65
  private
61
66
 
62
67
  def response
data/lib/senec/value.rb CHANGED
@@ -31,10 +31,7 @@ module Senec
31
31
  end
32
32
 
33
33
  def hex2float(hex)
34
- [ "0x#{hex}".to_i(16) ].
35
- pack('L').
36
- unpack1('F').
37
- round(1)
34
+ ["0x#{hex}".to_i(16)].pack('L').unpack1('F').round(1)
38
35
  end
39
36
 
40
37
  def hex2int(hex)
data/lib/senec/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Senec
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
data/lib/senec.rb CHANGED
@@ -3,5 +3,4 @@ require 'senec/request'
3
3
 
4
4
  module Senec
5
5
  class Error < StandardError; end
6
- # Your code goes here...
7
6
  end
data/senec.gemspec CHANGED
@@ -8,13 +8,13 @@ Gem::Specification.new do |spec|
8
8
 
9
9
  spec.summary = 'Unofficial Ruby Client for SENEC Home'
10
10
  spec.description = 'Access your local SENEC Solar Battery Storage System'
11
- spec.homepage = 'https://github.com/ledermann/senec'
11
+ spec.homepage = 'https://github.com/solectrus/senec'
12
12
  spec.license = 'MIT'
13
- spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
13
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
14
14
 
15
15
  spec.metadata['homepage_uri'] = spec.homepage
16
- spec.metadata['source_code_uri'] = 'https://github.com/ledermann/senec'
17
- spec.metadata['changelog_uri'] = 'https://github.com/ledermann/releases'
16
+ spec.metadata['source_code_uri'] = 'https://github.com/solectrus/senec'
17
+ spec.metadata['changelog_uri'] = 'https://github.com/solectrus/senec/releases'
18
18
 
19
19
  # Specify which files should be added to the gem when it is released.
20
20
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: senec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Ledermann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-13 00:00:00.000000000 Z
11
+ date: 2021-10-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Access your local SENEC Solar Battery Storage System
14
14
  email:
@@ -17,10 +17,10 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".github/workflows/push.yml"
20
21
  - ".gitignore"
21
22
  - ".rspec"
22
23
  - ".rubocop.yml"
23
- - ".travis.yml"
24
24
  - CODE_OF_CONDUCT.md
25
25
  - Gemfile
26
26
  - LICENSE.txt
@@ -34,13 +34,13 @@ files:
34
34
  - lib/senec/value.rb
35
35
  - lib/senec/version.rb
36
36
  - senec.gemspec
37
- homepage: https://github.com/ledermann/senec
37
+ homepage: https://github.com/solectrus/senec
38
38
  licenses:
39
39
  - MIT
40
40
  metadata:
41
- homepage_uri: https://github.com/ledermann/senec
42
- source_code_uri: https://github.com/ledermann/senec
43
- changelog_uri: https://github.com/ledermann/releases
41
+ homepage_uri: https://github.com/solectrus/senec
42
+ source_code_uri: https://github.com/solectrus/senec
43
+ changelog_uri: https://github.com/solectrus/senec/releases
44
44
  post_install_message:
45
45
  rdoc_options: []
46
46
  require_paths:
@@ -49,14 +49,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 2.5.0
52
+ version: 2.6.0
53
53
  required_rubygems_version: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  requirements: []
59
- rubygems_version: 3.2.5
59
+ rubygems_version: 3.2.28
60
60
  signing_key:
61
61
  specification_version: 4
62
62
  summary: Unofficial Ruby Client for SENEC Home
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7.2
6
- before_install: gem install bundler -v 2.1.4