ewelink 3.1.0 → 3.2.0
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 +4 -4
- data/README.mdown +5 -0
- data/VERSION +1 -1
- data/lib/ewelink/api.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9b83156bba48622088845d22bd8fc3b559d6e8732acf4664ba35886c6c19d35
|
4
|
+
data.tar.gz: d69303e93b04b56fd713fc27220d15c4ab66ca767190a289d6440932dc468532
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa3fd8b8a36ad7e4570db2941ebdffc1d134106ea40ce93866eaebe7b81a4cc0a35920f5366a48c0a9141476101cc03be42adf244b15bcf98eeec64b0e77a312
|
7
|
+
data.tar.gz: d98f59eaec9c582dd0627a52a392c45e98e351676b69d36f081df4ec819153bd32e340ced77440152c674d58013f413d8e42a5e86a50f65d57efce5782f26943
|
data/README.mdown
CHANGED
@@ -75,6 +75,11 @@ api = Ewelink::Api.new(email: 'john@example.com', password: 'secr$t')
|
|
75
75
|
api.press_rf_bridge_button!(button[:uuid])
|
76
76
|
```
|
77
77
|
|
78
|
+
### Additional options
|
79
|
+
|
80
|
+
- `update_devices_status_on_connect` (`true` | `false`): To update devices
|
81
|
+
status (on, off) when connecting to Ewelink API (default: `false`).
|
82
|
+
|
78
83
|
### Configuring logger
|
79
84
|
|
80
85
|
In order to have some debug informations about what kagu does, you could
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.2.0
|
data/lib/ewelink/api.rb
CHANGED
@@ -18,11 +18,12 @@ module Ewelink
|
|
18
18
|
|
19
19
|
attr_reader :email, :password, :phone_number
|
20
20
|
|
21
|
-
def initialize(email: nil, password:, phone_number: nil)
|
21
|
+
def initialize(email: nil, password:, phone_number: nil, update_devices_status_on_connect: false)
|
22
22
|
@email = email.presence.try(:strip)
|
23
23
|
@mutexs = {}
|
24
24
|
@password = password.presence || raise(Error.new(":password must be specified"))
|
25
25
|
@phone_number = phone_number.presence.try(:strip)
|
26
|
+
@update_devices_status_on_connect = update_devices_status_on_connect.present?
|
26
27
|
@web_socket_authenticated = false
|
27
28
|
@web_socket_switches_statuses = {}
|
28
29
|
|
@@ -198,6 +199,10 @@ module Ewelink
|
|
198
199
|
true
|
199
200
|
end
|
200
201
|
|
202
|
+
def update_devices_status_on_connect?
|
203
|
+
@update_devices_status_on_connect
|
204
|
+
end
|
205
|
+
|
201
206
|
private
|
202
207
|
|
203
208
|
def api_key
|
@@ -411,6 +416,7 @@ module Ewelink
|
|
411
416
|
if json['apikey'].present? && !@web_socket_authenticated && json['apikey'] == api_key
|
412
417
|
@web_socket_authenticated = true
|
413
418
|
Ewelink.logger.debug(self.class.name) { "WebSocket successfully authenticated API key: #{json['apikey'].truncate(16).inspect}" }
|
419
|
+
Thread.new { switches.each { |switch| switch_on?(switch[:uuid]) } } if update_devices_status_on_connect?
|
414
420
|
end
|
415
421
|
|
416
422
|
if json['deviceid'].present? && json['params'].is_a?(Hash) && json['params']['switch'].present?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ewelink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Toulotte
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|