huginn_renault_ze_agent 0.1.5 → 0.1.7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32def01ce48f435627926af651b7c7101321ee9ea2e68987231814e32512d5c8
|
4
|
+
data.tar.gz: b70fb6f9c144f3fd28701e442465e5443d8681c8af889c24772152aa000d8e0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0461a1e5c9ae97440a7d2a030030b94d544eaa1a625da097e56aea0a03ac4dfdf2bed426b55cb44ef30dfe670903207371e550ed3102b84deaf4ab7bf0e33d5
|
7
|
+
data.tar.gz: 1fd129a0fdc9635c66e2846db6453e03e76fa122ddba7880f6ddaa405f0b02a5a2d5adb20b09766e7605dae12c7401ca4e6b12a65765ed9d8898721d613627d6
|
@@ -50,13 +50,16 @@ module Agents
|
|
50
50
|
def check
|
51
51
|
username = interpolated["username"].present? ? interpolated["username"] : credential("renault_ze_username")
|
52
52
|
password = interpolated["password"].present? ? interpolated["password"] : credential("renault_ze_password")
|
53
|
+
redacted_password = password.size.times.map { "•" }.join
|
54
|
+
log("Logging in #{username} with #{redacted_password}...")
|
55
|
+
|
53
56
|
service = RenaultZE::Client.new(username, password)
|
54
57
|
|
55
58
|
begin
|
56
59
|
content = service.get_battery(service.login())
|
57
60
|
rescue
|
58
61
|
error("Could not fetch battery level: #{$!}")
|
59
|
-
|
62
|
+
return
|
60
63
|
end
|
61
64
|
|
62
65
|
if memory["last_update"] != content["last_update"]
|
@@ -1,18 +1,15 @@
|
|
1
1
|
module RenaultZE
|
2
2
|
class Client
|
3
|
+
API_BASE_URL = 'https://www.services.renault-ze.com/api/'
|
4
|
+
|
3
5
|
def initialize(username, password)
|
4
6
|
@username = username
|
5
7
|
@password = password
|
6
8
|
end
|
7
9
|
|
8
10
|
def login
|
9
|
-
response = HTTParty.post(
|
10
|
-
"
|
11
|
-
headers: {
|
12
|
-
"Accept": "application/json",
|
13
|
-
"Content-Type": "application/json",
|
14
|
-
"User-Agent": "Huginn/2019"
|
15
|
-
},
|
11
|
+
response = HTTParty.post(API_BASE_URL + "user/login",
|
12
|
+
headers: {"Content-Type": "application/json"},
|
16
13
|
body: {username: @username, password: @password}.to_json
|
17
14
|
)
|
18
15
|
raise "Login - Unexpected response code: #{response}" unless response.code == 200
|
@@ -28,13 +25,8 @@ module RenaultZE
|
|
28
25
|
raise "Battery - Missing token in input: #{creds}" if creds[:token].nil?
|
29
26
|
raise "Battery - Missing VIN in input: #{creds}" if creds[:vin].nil?
|
30
27
|
|
31
|
-
response = HTTParty.get(
|
32
|
-
"
|
33
|
-
headers: {
|
34
|
-
"Accept": "application/json",
|
35
|
-
"Authorization": "Bearer #{creds[:token]}",
|
36
|
-
"User-Agent": "Huginn/2019"
|
37
|
-
}
|
28
|
+
response = HTTParty.get(API_BASE_URL + "/vehicle/#{creds[:vin]}/battery",
|
29
|
+
headers: {"Authorization": "Bearer #{creds[:token]}"}
|
38
30
|
)
|
39
31
|
raise "Battery - Unexpected response code: #{response}" unless response.code == 200
|
40
32
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: huginn_renault_ze_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Schoenig
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|