alpha_ess 1.2 → 1.2.2

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: 3403efae3e758f4f8ef2593edc6bdf9d268a34367ff99ab93a78cc80d007828f
4
- data.tar.gz: 54233da976a52b1dd3c6a46cdcec89932398f9272eeedc54fc384714d27d3afc
3
+ metadata.gz: c81cbe7a51a271d210972e96ba79ab88775e6a8021d822572072b056cc0c4b2a
4
+ data.tar.gz: 53cfca26ba154a13195698cf0068b926229f10080e496c9d91b08298b6cf9dc2
5
5
  SHA512:
6
- metadata.gz: 0d985dbad128c6b41adf906cf41d0dfe8ffcbf2fbf9ece3bfa83d20cca55bc4a8168d47daf8db80607bf52c750d2b14450dabc0a2a0a3c3248fa94001b96f0f3
7
- data.tar.gz: 92e0ae0059e060ac6ccb7a6546df84b57b246188b82192768a713c5d81a0a62639f49902f21be0a62a6b26aedb3ed533219c4cb7dd30b0a049a772b3b23fe9f3
6
+ metadata.gz: b02e6738a07f151c35872be94e15c89a8f50031502d2ac3633eef728361ead1744c48af002f208e90c0215ede33014d9ab3133f2e5a36558b52c892a6ee1cc6a
7
+ data.tar.gz: 7013a66d7298c9a34b159026131ef02c993d8806dd32465ae950dea78b4f18318041e931af3238d4eb488b20617ea6f917c43d9ea1c002a46b00709d59769170
data/README.md CHANGED
@@ -112,7 +112,6 @@ puts "
112
112
  Batteriebezug / Ladung: #{data["pbat"]}
113
113
  Verbrauch: #{data["pbat"] + data["ppv1"].to_f + netz}
114
114
 
115
-
116
115
  "
117
116
  ```
118
117
 
data/alpha_ess.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'alpha_ess'
3
- spec.version = '1.2'
3
+ spec.version = '1.2.2'
4
4
  spec.date = '2022-10-31'
5
5
  spec.summary = "Alpha Ess API Calls"
6
6
  spec.description = "a Ruby class for Alpha-Ess-API-Calls"
data/lib/alpha_ess.rb CHANGED
@@ -26,26 +26,19 @@ class AlphaEss
26
26
  end
27
27
 
28
28
  def get_last_power_data()
29
- body = {
30
- "sys_sn" => @serial,
31
- "noLoading" => true
32
- }
33
- url = "https://cloud.alphaess.com/api/ESS/GetLastPowerDataBySN"
34
- res = HTTParty.post(url, headers: header(), body: body.to_json)
29
+ #body = {
30
+ # "sys_sn" => @serial,
31
+ # "noLoading" => true
32
+ #}
33
+ url = "https://cloud.alphaess.com/api/ESS/GetLastPowerDataBySN?sys_sn=#{@serial}&noLoading=true"
34
+ #res = HTTParty.post(url, headers: header(), body: body.to_json)
35
+ res = HTTParty.get(url, headers: header())
35
36
  res.parsed_response["data"]
36
37
  end
37
38
 
38
39
  def get_stics_by_period(beginDay = Time.now.strftime("%Y-%m-%d"), endDay = Time.now.strftime("%Y-%m-%d"))
39
- body = {
40
- "beginDay" => beginDay,
41
- "endDay" => endDay,
42
- "tday" => Time.now.strftime("%Y-%m-%d"),
43
- "isOEM" => 0,
44
- "SN" => @serial,
45
- "noLoading" => true
46
- }
47
- url = "https://cloud.alphaess.com/api/Power/SticsByPeriod"
48
- res = HTTParty.post(url, headers: header(), body: body.to_json)
40
+ url = "https://cloud.alphaess.com/api/Power/SticsByPeriod?beginDay=#{beginDay}&endDay=#{endDay}&tday=#{tday}&isOEM=0&SN=#{@serial}&noLoading=true"
41
+ res = HTTParty.get(url, headers: header())
49
42
  res.parsed_response["data"]
50
43
  end
51
44
 
@@ -102,10 +95,11 @@ class AlphaEss
102
95
  "username" => @username,
103
96
  "password" => @password
104
97
  }
105
- res = HTTParty.post(url, headers: {
98
+ header = {
106
99
  "Accept" => "application/json",
107
100
  "Content-Type" => "application/json;charset=UTF-8"
108
- }.update(secure_header_addon()), body: body.to_json)
101
+ }.update(secure_header_addon())
102
+ res = HTTParty.post(url, headers: header, body: body.to_json)
109
103
  @token = res.parsed_response["data"]["AccessToken"]
110
104
  @token_valid_to = Time.now.to_i+36000
111
105
  save_token()
@@ -115,7 +109,7 @@ class AlphaEss
115
109
  # thanks to https://github.com/CharlesGillanders
116
110
  t = Time.now.to_i
117
111
  {
118
- "authtimestamp" => t,
112
+ "authtimestamp" => t.to_s,
119
113
  "authsignature" => "#{AUTHPREFIX}#{Digest::SHA2.new(512).hexdigest("#{AUTHCONSTANT}#{t}")}#{AUTHSUFFIX}"
120
114
  }
121
115
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alpha_ess
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oliver Gaida
@@ -46,7 +46,6 @@ extra_rdoc_files: []
46
46
  files:
47
47
  - LICENSE.md
48
48
  - README.md
49
- - alpha_ess-1.1.gem
50
49
  - alpha_ess.gemspec
51
50
  - images/b965404834760626afe73785811995faa1629d2ab66a53f966443fbf22463a67.png
52
51
  - lib/alpha_ess.rb
data/alpha_ess-1.1.gem DELETED
Binary file