senec 0.2.0 → 0.5.0

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: e01c953be78bd25556bdc237430130f7dec23a0d48d6bf0ba345c4148f132e1e
4
- data.tar.gz: 29d87125f60177f5110a7efe7d4016c1390fcb03362f37e914630359ad327989
3
+ metadata.gz: 16c3c9c4abc76f4aefff00ebf5d5bec743f32f6a974c82ad28687067177f38b9
4
+ data.tar.gz: e1688029cc73db36e58212956fb483697036159e45fd5e76082efe85d42c444f
5
5
  SHA512:
6
- metadata.gz: 2a0e8e2fdedc6c7189f53df01abc35bffc427ce561ac5f66f4e129bcd53242f58b4ccf499ec4560d465b939ec7f07482c755affc287a636dba7824ebd668288c
7
- data.tar.gz: 35a99bb5c476a589186084a5a9055fa56f7d0d6731dcc8e2c576567387b40158423a30d10164ca84ddadd5df89f82cb4bed72d16d80bf9a17f9a52f989881525
6
+ metadata.gz: c25862ac9c3ff78553ac5b651335c2ad653bbbc1746aa0164cdac8e67e65984104e0b453069cd4222f1a1bb188ffc1115cf41d7e1e21628dbd70aee7735cfb72
7
+ data.tar.gz: 9b0a3e4a5586ccdec41978614364951a3f616287dd8ed029ca66b707987656a45930d7688029cd1e705e9fd51833a4ec62bd9dea432c77bf26118e0676eecaec
@@ -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.1'
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/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 Georg Ledermann
3
+ Copyright (c) 2020,2022 Georg Ledermann
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -31,8 +31,13 @@ puts "Battery fuel charge: #{request.bat_fuel_charge} %"
31
31
  puts "Battery charge current: #{request.bat_charge_current} A"
32
32
  puts "Battery voltage: #{request.bat_voltage} V"
33
33
  puts "\n"
34
+ puts "Case temperature: #{request.case_temp} °C"
35
+ puts "\n"
36
+ puts "Wallbox charge power: [ #{request.wallbox_charge_power.join(',')} ] W"
37
+ puts "\n"
34
38
  puts "Grid power: #{request.grid_power} W"
35
39
  puts "Current state of the system: #{request.current_state}"
40
+ puts "Measure time: #{Time.at request.measure_time}"
36
41
 
37
42
  # Example result:
38
43
  #
@@ -44,8 +49,13 @@ puts "Current state of the system: #{request.current_state}"
44
49
  # Battery charge current: 19.8 A
45
50
  # Battery voltage: 49.2 V
46
51
  #
52
+ # Case temperature: 31.3 °C
53
+ #
54
+ # Wallbox charge power: [ 8680, 0, 0, 0 ] W
55
+ #
47
56
  # Grid power: 315 W
48
57
  # Current state of the system: CHARGE
58
+ # Measure time: 2021-10-06 17:50:22 +0200
49
59
  ```
50
60
 
51
61
  ## Development
@@ -56,7 +66,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
56
66
 
57
67
  ## Contributing
58
68
 
59
- 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).
69
+ 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).
60
70
 
61
71
 
62
72
  ## License
@@ -65,4 +75,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
65
75
 
66
76
  ## Code of Conduct
67
77
 
68
- 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).
78
+ 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',
@@ -95,36 +95,28 @@ module Senec # rubocop:disable Metrics/ModuleLength
95
95
  91 => 'EARTH FAULT'
96
96
  }.freeze
97
97
 
98
- # Taken from https://gist.github.com/smashnet/82ad0b9d7f0ba2e5098e6649ba08f88a
98
+ # For a full list of available vars, see http://[IP-of-your-SENEC]/vars.html
99
+ # Comments taken from https://gist.github.com/smashnet/82ad0b9d7f0ba2e5098e6649ba08f88a
99
100
  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)
101
+ STATISTIC: {
102
+ CURRENT_STATE: '', # Current state of the system (int, see SYSTEM_STATE_NAME)
103
+ MEASURE_TIME: '' # Unix timestamp for above values (ms)
109
104
  },
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
105
+ ENERGY: {
106
+ GUI_BAT_DATA_CURRENT: '', # Battery charge current: negative if discharging, positiv if charging (A)
107
+ GUI_BAT_DATA_FUEL_CHARGE: '', # Remaining battery (percent)
108
+ GUI_BAT_DATA_POWER: '', # Battery charge power: negative if discharging, positiv if charging (W)
109
+ GUI_BAT_DATA_VOLTAGE: '', # Battery voltage (V)
110
+ GUI_GRID_POW: '', # Grid power: negative if exporting, positiv if importing (W)
111
+ GUI_HOUSE_POW: '', # House power consumption (W)
112
+ GUI_INVERTER_POWER: '', # PV production (W)
113
+ STAT_HOURS_OF_OPERATION: '' # Appliance hours of operation
119
114
  },
120
- 'BMS': {
121
- 'CHARGED_ENERGY': '', # List: Charged energy per battery
122
- 'DISCHARGED_ENERGY': '', # List: Discharged energy per battery
123
- 'CYCLES': '' # List: Cycles per battery
115
+ TEMPMEASURE: {
116
+ CASE_TEMP: ''
124
117
  },
125
- 'PV1': {
126
- 'POWER_RATIO': '', # Grid export limit (percent)
127
- 'P_TOTAL': '' # ?
118
+ WALLBOX: {
119
+ APPARENT_CHARGING_POWER: ''
128
120
  }
129
121
  }.freeze
130
122
  end
data/lib/senec/request.rb CHANGED
@@ -44,6 +44,17 @@ module Senec
44
44
  Senec::Value.new(value).to_i
45
45
  end
46
46
 
47
+ def wallbox_charge_power
48
+ response.dig('WALLBOX', 'APPARENT_CHARGING_POWER').map do |value|
49
+ Senec::Value.new(value).to_i
50
+ end
51
+ end
52
+
53
+ def case_temp
54
+ value = response.dig('TEMPMEASURE', 'CASE_TEMP')
55
+ Senec::Value.new(value).to_f
56
+ end
57
+
47
58
  def current_state
48
59
  value = response.dig('STATISTIC', 'CURRENT_STATE')
49
60
  state = Senec::Value.new(value).to_i
@@ -51,6 +62,11 @@ module Senec
51
62
  STATE_NAMES[state]
52
63
  end
53
64
 
65
+ def measure_time
66
+ value = response.dig('STATISTIC', 'MEASURE_TIME')
67
+ Senec::Value.new(value).to_i
68
+ end
69
+
54
70
  private
55
71
 
56
72
  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.2.0'.freeze
2
+ VERSION = '0.5.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,14 @@ 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
+ spec.metadata['rubygems_mfa_required'] = 'true'
18
19
 
19
20
  # Specify which files should be added to the gem when it is released.
20
21
  # 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.2.0
4
+ version: 0.5.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: 2020-12-22 00:00:00.000000000 Z
11
+ date: 2022-03-09 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,14 @@ 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
+ rubygems_mfa_required: 'true'
44
45
  post_install_message:
45
46
  rdoc_options: []
46
47
  require_paths:
@@ -49,14 +50,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
50
  requirements:
50
51
  - - ">="
51
52
  - !ruby/object:Gem::Version
52
- version: 2.5.0
53
+ version: 2.6.0
53
54
  required_rubygems_version: !ruby/object:Gem::Requirement
54
55
  requirements:
55
56
  - - ">="
56
57
  - !ruby/object:Gem::Version
57
58
  version: '0'
58
59
  requirements: []
59
- rubygems_version: 3.2.2
60
+ rubygems_version: 3.3.8
60
61
  signing_key:
61
62
  specification_version: 4
62
63
  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