stekker_easee 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +35 -26
- data/README.md +7 -11
- data/bin/release +28 -0
- data/lib/easee/charger.rb +12 -0
- data/lib/easee/client.rb +14 -1
- data/lib/easee/errors.rb +7 -1
- data/lib/easee/site.rb +3 -1
- data/lib/easee/state.rb +7 -2
- data/lib/easee/version.rb +1 -1
- data/lib/stekker_easee.rb +1 -0
- metadata +5 -4
- data/lib/easee.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1cb2855dca8dd2bd2bc7670e2da0db9b31c083e6dd35a80c0eacb78031d173f
|
4
|
+
data.tar.gz: 3aabf9fe36a3eb46f2af3062d1daca8db14946e39f6a69002472e0d9a185117d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b19294d36bbea358b1f67a97b0fd3a726c6d6b113596ce631adf8585b9731dc6af0e258597fe92414ecea34736b6cfd1232253d1b1b4925786e83e94e03b8759
|
7
|
+
data.tar.gz: 1c0d69be491fd212755acaea9fd1b0e7f24801cabe177e7c4aaa419088632d51c9be26b7b4e7db312ffd1394c71051abfeb263bbd0e344f0d83d84887357b38a
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stekker_easee (1.0.
|
4
|
+
stekker_easee (1.0.1)
|
5
5
|
activemodel
|
6
6
|
activesupport
|
7
7
|
faraday
|
@@ -10,16 +10,17 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activemodel (7.0.
|
14
|
-
activesupport (= 7.0.
|
15
|
-
activesupport (7.0.
|
13
|
+
activemodel (7.0.8)
|
14
|
+
activesupport (= 7.0.8)
|
15
|
+
activesupport (7.0.8)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
17
|
i18n (>= 1.6, < 2)
|
18
18
|
minitest (>= 5.1)
|
19
19
|
tzinfo (~> 2.0)
|
20
|
-
addressable (2.8.
|
20
|
+
addressable (2.8.5)
|
21
21
|
public_suffix (>= 2.0.2, < 6.0)
|
22
22
|
ast (2.4.2)
|
23
|
+
base64 (0.1.1)
|
23
24
|
concurrent-ruby (1.2.2)
|
24
25
|
crack (0.4.5)
|
25
26
|
rexml
|
@@ -51,61 +52,69 @@ GEM
|
|
51
52
|
faraday (~> 1.0)
|
52
53
|
gem-release (2.2.2)
|
53
54
|
hashdiff (1.0.1)
|
54
|
-
i18n (1.
|
55
|
+
i18n (1.14.1)
|
55
56
|
concurrent-ruby (~> 1.0)
|
56
57
|
json (2.6.3)
|
57
|
-
|
58
|
+
language_server-protocol (3.17.0.3)
|
59
|
+
minitest (5.20.0)
|
58
60
|
multipart-post (2.3.0)
|
59
|
-
parallel (1.
|
60
|
-
parser (3.2.
|
61
|
+
parallel (1.23.0)
|
62
|
+
parser (3.2.2.3)
|
61
63
|
ast (~> 2.4.1)
|
62
|
-
|
63
|
-
|
64
|
+
racc
|
65
|
+
public_suffix (5.0.3)
|
66
|
+
racc (1.7.1)
|
67
|
+
rack (3.0.8)
|
64
68
|
rainbow (3.1.1)
|
65
69
|
rake (13.0.6)
|
66
|
-
regexp_parser (2.
|
67
|
-
rexml (3.2.
|
70
|
+
regexp_parser (2.8.1)
|
71
|
+
rexml (3.2.6)
|
68
72
|
rspec (3.12.0)
|
69
73
|
rspec-core (~> 3.12.0)
|
70
74
|
rspec-expectations (~> 3.12.0)
|
71
75
|
rspec-mocks (~> 3.12.0)
|
72
|
-
rspec-core (3.12.
|
76
|
+
rspec-core (3.12.2)
|
73
77
|
rspec-support (~> 3.12.0)
|
74
|
-
rspec-expectations (3.12.
|
78
|
+
rspec-expectations (3.12.3)
|
75
79
|
diff-lcs (>= 1.2.0, < 2.0)
|
76
80
|
rspec-support (~> 3.12.0)
|
77
|
-
rspec-mocks (3.12.
|
81
|
+
rspec-mocks (3.12.6)
|
78
82
|
diff-lcs (>= 1.2.0, < 2.0)
|
79
83
|
rspec-support (~> 3.12.0)
|
80
|
-
rspec-support (3.12.
|
81
|
-
rubocop (1.
|
84
|
+
rspec-support (3.12.1)
|
85
|
+
rubocop (1.56.3)
|
86
|
+
base64 (~> 0.1.1)
|
82
87
|
json (~> 2.3)
|
88
|
+
language_server-protocol (>= 3.17.0)
|
83
89
|
parallel (~> 1.10)
|
84
|
-
parser (>= 3.2.
|
90
|
+
parser (>= 3.2.2.3)
|
85
91
|
rainbow (>= 2.2.2, < 4.0)
|
86
92
|
regexp_parser (>= 1.8, < 3.0)
|
87
93
|
rexml (>= 3.2.5, < 4.0)
|
88
|
-
rubocop-ast (>= 1.
|
94
|
+
rubocop-ast (>= 1.28.1, < 2.0)
|
89
95
|
ruby-progressbar (~> 1.7)
|
90
96
|
unicode-display_width (>= 2.4.0, < 3.0)
|
91
|
-
rubocop-ast (1.
|
97
|
+
rubocop-ast (1.29.0)
|
92
98
|
parser (>= 3.2.1.0)
|
93
|
-
rubocop-capybara (2.
|
99
|
+
rubocop-capybara (2.18.0)
|
94
100
|
rubocop (~> 1.41)
|
95
|
-
rubocop-
|
101
|
+
rubocop-factory_bot (2.23.1)
|
102
|
+
rubocop (~> 1.33)
|
103
|
+
rubocop-rails (2.21.0)
|
96
104
|
activesupport (>= 4.2.0)
|
97
105
|
rack (>= 1.1)
|
98
106
|
rubocop (>= 1.33.0, < 2.0)
|
99
|
-
rubocop-rspec (2.
|
107
|
+
rubocop-rspec (2.24.0)
|
100
108
|
rubocop (~> 1.33)
|
101
109
|
rubocop-capybara (~> 2.17)
|
110
|
+
rubocop-factory_bot (~> 2.22)
|
102
111
|
ruby-progressbar (1.13.0)
|
103
112
|
ruby2_keywords (0.0.5)
|
104
|
-
timecop (0.9.
|
113
|
+
timecop (0.9.8)
|
105
114
|
tzinfo (2.0.6)
|
106
115
|
concurrent-ruby (~> 1.0)
|
107
116
|
unicode-display_width (2.4.2)
|
108
|
-
webmock (3.
|
117
|
+
webmock (3.19.1)
|
109
118
|
addressable (>= 2.8.0)
|
110
119
|
crack (>= 0.3.2)
|
111
120
|
hashdiff (>= 0.4.0, < 2.0.0)
|
data/README.md
CHANGED
@@ -61,15 +61,11 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/stekke
|
|
61
61
|
## Publishing
|
62
62
|
|
63
63
|
```bash
|
64
|
-
#
|
65
|
-
#
|
66
|
-
|
67
|
-
|
68
|
-
#
|
69
|
-
|
70
|
-
gem
|
71
|
-
|
72
|
-
# Push the commit and tag to git
|
73
|
-
git push
|
74
|
-
git push --tags
|
64
|
+
# - bumps the gem version to the next major, minor or patch version.
|
65
|
+
# - creates commit for the version bump
|
66
|
+
# - tags the commit
|
67
|
+
# - pushes the commit and tag
|
68
|
+
# - publishes the gem to Rubygems
|
69
|
+
bin/release [major|minor|patch]
|
70
|
+
# See also https://github.com/svenfuchs/gem-release#gem-bump
|
75
71
|
```
|
data/bin/release
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
# Read major/minor/patch argument
|
7
|
+
version="$1"
|
8
|
+
|
9
|
+
# Do a pretend version bump to determine what the new version should be
|
10
|
+
bumped_version=$(gem bump "$version" --pretend --no-commit | awk '{ print $4 }' | tr -d '[:space:]')
|
11
|
+
|
12
|
+
# Use ruby to get the root level directory name
|
13
|
+
gem_name=$(ruby -e "puts File.basename(Dir.pwd)")
|
14
|
+
|
15
|
+
# Update version file
|
16
|
+
gem bump --version "$bumped_version" --no-commit
|
17
|
+
|
18
|
+
# Run bundle install to ensure gem version in Gemfile is updated
|
19
|
+
bundle install
|
20
|
+
|
21
|
+
# Stage Gemfile.lock and the version file
|
22
|
+
git add Gemfile.lock "lib/$gem_name/version.rb"
|
23
|
+
|
24
|
+
# Finally create the bump commit
|
25
|
+
git commit -m "Bump $gem_name to $bumped_version"
|
26
|
+
|
27
|
+
# Create a tag, push the commit and tag, and release to Rubygems
|
28
|
+
gem bump --version "$bumped_version" --no-commit --tag --push --release
|
data/lib/easee/client.rb
CHANGED
@@ -30,6 +30,13 @@ module Easee
|
|
30
30
|
post("/api/chargers/#{charger_id}/pair", query: { pinCode: pin_code })
|
31
31
|
end
|
32
32
|
|
33
|
+
# https://developer.easee.cloud/reference/get_api-chargers
|
34
|
+
def chargers
|
35
|
+
get("/api/chargers").then do |response|
|
36
|
+
response.body.map { |data| Charger.new(data) }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
33
40
|
# https://developer.easee.cloud/reference/get_api-chargers-id-state
|
34
41
|
def state(charger_id)
|
35
42
|
get("/api/chargers/#{charger_id}/state")
|
@@ -46,11 +53,13 @@ module Easee
|
|
46
53
|
post("/api/chargers/#{charger_id}/commands/resume_charging")
|
47
54
|
end
|
48
55
|
|
56
|
+
# https://developer.easee.cloud/reference/get_api-chargers-id-config
|
49
57
|
def configuration(charger_id)
|
50
58
|
get("/api/chargers/#{charger_id}/config")
|
51
59
|
.then { |response| Configuration.new(response.body) }
|
52
60
|
end
|
53
61
|
|
62
|
+
# https://developer.easee.cloud/reference/get_api-chargers-id-site
|
54
63
|
def site(charger_id)
|
55
64
|
get("/api/chargers/#{charger_id}/site")
|
56
65
|
.then { |response| Site.new(response.body) }
|
@@ -108,7 +117,11 @@ module Easee
|
|
108
117
|
retry
|
109
118
|
end
|
110
119
|
rescue Faraday::Error => e
|
111
|
-
|
120
|
+
if e.response_status == 429 # HTTP 429 TooManyRequests
|
121
|
+
raise Errors::RateLimitExceeded.new("Rate limit exceeded", e.response)
|
122
|
+
else
|
123
|
+
raise Errors::RequestFailed.new("Request returned status #{e.response_status}", e.response)
|
124
|
+
end
|
112
125
|
end
|
113
126
|
|
114
127
|
def access_token
|
data/lib/easee/errors.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Easee
|
2
2
|
module Errors
|
3
|
-
class Base < ::StandardError
|
3
|
+
class Base < ::StandardError
|
4
|
+
def retryable? = false
|
5
|
+
end
|
4
6
|
|
5
7
|
class RequestFailed < Base
|
6
8
|
attr_reader :response
|
@@ -10,5 +12,9 @@ module Easee
|
|
10
12
|
super(message)
|
11
13
|
end
|
12
14
|
end
|
15
|
+
|
16
|
+
class RateLimitExceeded < RequestFailed
|
17
|
+
def retryable? = true
|
18
|
+
end
|
13
19
|
end
|
14
20
|
end
|
data/lib/easee/site.rb
CHANGED
@@ -9,12 +9,14 @@ module Easee
|
|
9
9
|
def building_number = address.fetch(:buildingNumber)
|
10
10
|
def zip = address.fetch(:zip)
|
11
11
|
def area = address.fetch(:area)
|
12
|
-
def country_id =
|
12
|
+
def country_id = country[:id]
|
13
13
|
def latitude = address.fetch(:latitude)
|
14
14
|
def longitude = address.fetch(:longitude)
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
+
def country = address.fetch(:country) || {}
|
19
|
+
|
18
20
|
def address
|
19
21
|
@address ||= @data.fetch(:address)
|
20
22
|
end
|
data/lib/easee/state.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Easee
|
2
2
|
class State
|
3
|
+
OP_MODE_UNKNOWN = :unknown
|
4
|
+
|
3
5
|
CHARGER_OP_MODES = {
|
4
6
|
0 => :offline,
|
5
7
|
1 => :disconnected,
|
@@ -21,12 +23,15 @@ module Easee
|
|
21
23
|
def meter_reading
|
22
24
|
MeterReading.new(
|
23
25
|
reading_kwh: @data.fetch(:lifetimeEnergy),
|
24
|
-
timestamp: Time.
|
26
|
+
timestamp: Time.zone.parse(@data.fetch(:latestPulse)),
|
25
27
|
)
|
26
28
|
end
|
27
29
|
|
28
30
|
private
|
29
31
|
|
30
|
-
def charger_op_mode
|
32
|
+
def charger_op_mode
|
33
|
+
numeric_op_mode = @data.fetch(:chargerOpMode)
|
34
|
+
CHARGER_OP_MODES.fetch(numeric_op_mode) { OP_MODE_UNKNOWN }
|
35
|
+
end
|
31
36
|
end
|
32
37
|
end
|
data/lib/easee/version.rb
CHANGED
data/lib/stekker_easee.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stekker_easee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Team Stekker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -83,9 +83,10 @@ files:
|
|
83
83
|
- README.md
|
84
84
|
- Rakefile
|
85
85
|
- bin/console
|
86
|
+
- bin/release
|
86
87
|
- bin/setup
|
87
88
|
- easee.gemspec
|
88
|
-
- lib/easee.rb
|
89
|
+
- lib/easee/charger.rb
|
89
90
|
- lib/easee/client.rb
|
90
91
|
- lib/easee/configuration.rb
|
91
92
|
- lib/easee/errors.rb
|
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
118
|
- !ruby/object:Gem::Version
|
118
119
|
version: '0'
|
119
120
|
requirements: []
|
120
|
-
rubygems_version: 3.4.
|
121
|
+
rubygems_version: 3.4.18
|
121
122
|
signing_key:
|
122
123
|
specification_version: 4
|
123
124
|
summary: Connect to your Easee charger
|
data/lib/easee.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require "faraday"
|
2
|
-
require "active_support/core_ext/time/calculations"
|
3
|
-
require "active_support/isolated_execution_state"
|
4
|
-
require "active_support/core_ext/hash"
|
5
|
-
|
6
|
-
require_relative "easee/version"
|
7
|
-
require_relative "easee/client"
|
8
|
-
require_relative "easee/configuration"
|
9
|
-
require_relative "easee/errors"
|
10
|
-
require_relative "easee/meter_reading"
|
11
|
-
require_relative "easee/site"
|
12
|
-
require_relative "easee/state"
|
13
|
-
|
14
|
-
module Easee
|
15
|
-
end
|