senec 0.8.0 → 0.9.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: 1742fde56f587e423ac2c22d38d8cfee11fc324faa7b026af09c1419e2a93841
4
- data.tar.gz: e5d4184d3d24741d76baedecf0a565fe7aad6685f6c3c2f8f745ce22a75a38b2
3
+ metadata.gz: c99082ac76970b9dd8c23b3d847c329bae0a1499108cb4da23cc6890db0799c1
4
+ data.tar.gz: 2a7b3fd24ec219b64ad3345745d3dbe783293327849bf225356d63b3b02a1ca8
5
5
  SHA512:
6
- metadata.gz: d3d1f2a65475ae606ab0c6f4f13eed3363d9cd2c8bd0e7f57cc4fe730492410295860800b1e1027e18bbd2ad5abc7b01012ec6c7fe7286c304b58e025a8cd110
7
- data.tar.gz: 3dea00f3618c57301a9509cc5de3b0e14df42f9a4cefff6a82a047a73073602cbe9fc2ce2b5f0438c8f1539e1cb5784fe526198373990a8a2f271ef0e232acb9
6
+ metadata.gz: 046047abcc8df94341e6da4e1209bd828045a93c0d64f4970b49fdffa41afd88c815194b64372ceee09cacf30dbdacdd12be36a6d6d0bdf40a6b5a8f04a367c7
7
+ data.tar.gz: 4620d56810a324f10a9a14607afb35f198e6275c77eea18d41aa5ee1339ce0f97e207ba82a5f9d12636bcaacef8709e273dcd8dc1f524bf9b0ea2825b8a06421
@@ -2,11 +2,8 @@ module Senec
2
2
  # For a full list of available vars, see http://[IP-of-your-SENEC]/vars.html
3
3
  # Comments taken from https://gist.github.com/smashnet/82ad0b9d7f0ba2e5098e6649ba08f88a
4
4
  BASIC_REQUEST = {
5
- STATISTIC: {
6
- CURRENT_STATE: '', # Current state of the system (int, see SYSTEM_STATE_NAME)
7
- MEASURE_TIME: '' # Unix timestamp for above values (ms)
8
- },
9
5
  ENERGY: {
6
+ STAT_STATE: '', # Current state of the system (int, see SYSTEM_STATE_NAME)
10
7
  GUI_BAT_DATA_CURRENT: '', # Battery charge current: negative if discharging, positiv if charging (A)
11
8
  GUI_BAT_DATA_FUEL_CHARGE: '', # Remaining battery (percent)
12
9
  GUI_BAT_DATA_POWER: '', # Battery charge power: negative if discharging, positiv if charging (W)
@@ -16,6 +13,10 @@ module Senec
16
13
  GUI_INVERTER_POWER: '', # PV production (W)
17
14
  STAT_HOURS_OF_OPERATION: '' # Appliance hours of operation
18
15
  },
16
+ RTC: {
17
+ UTC_OFFSET: '',
18
+ WEB_TIME: ''
19
+ },
19
20
  PV1: {
20
21
  MPP_POWER: '' # List: MPP power (W)
21
22
  },
data/lib/senec/request.rb CHANGED
@@ -53,7 +53,7 @@ module Senec
53
53
  end
54
54
 
55
55
  def current_state
56
- get('STATISTIC', 'CURRENT_STATE')
56
+ get('ENERGY', 'STAT_STATE')
57
57
  end
58
58
 
59
59
  def current_state_name
@@ -63,7 +63,10 @@ module Senec
63
63
  end
64
64
 
65
65
  def measure_time
66
- get('STATISTIC', 'MEASURE_TIME')
66
+ web_time = get('RTC', 'WEB_TIME')
67
+ utc_offset = get('RTC', 'UTC_OFFSET')
68
+
69
+ web_time - (utc_offset * 60)
67
70
  end
68
71
 
69
72
  private
data/lib/senec/value.rb CHANGED
@@ -1,14 +1,17 @@
1
1
  module Senec
2
2
  class Value
3
- def initialize(data)
4
- @data = data
3
+ def initialize(raw)
4
+ @raw = raw
5
+ @prefix, @value = raw&.split('_')
5
6
  end
6
7
 
7
- def decoded
8
- parts = @data.split('_')
9
- prefix = parts[0]
10
- value = parts[1]
8
+ attr_reader :prefix, :value, :raw
9
+
10
+ def valid?
11
+ prefix && PREFIXES.include?(prefix)
12
+ end
11
13
 
14
+ def decoded
12
15
  case prefix
13
16
  when 'fl'
14
17
  decoded_float(value)
@@ -18,7 +21,7 @@ module Senec
18
21
  value
19
22
  # TODO: There are some more prefixes to handle
20
23
  else
21
- raise Senec::DecodingError, "Unknown value '#{@data}'"
24
+ raise Senec::DecodingError, "Unknown value '#{@raw}'"
22
25
  end
23
26
  end
24
27
 
@@ -28,6 +31,9 @@ module Senec
28
31
 
29
32
  private
30
33
 
34
+ PREFIXES = %w[fl i3 u1 u3 u6 u8 st].freeze
35
+ private_constant :PREFIXES
36
+
31
37
  def decoded_float(hex)
32
38
  ["0x#{hex}".to_i(16)].pack('L').unpack1('F').round(1)
33
39
  end
data/lib/senec/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Senec
2
- VERSION = '0.8.0'.freeze
2
+ VERSION = '0.9.0'.freeze
3
3
  end
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.8.0
4
+ version: 0.9.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: 2023-08-17 00:00:00.000000000 Z
11
+ date: 2023-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
- rubygems_version: 3.4.18
76
+ rubygems_version: 3.4.19
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Unofficial Ruby Client for SENEC Home