ewelink 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/ewelink/api.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 957d00b0d8171519a48b1cf828cbd78c21dbde34b93f2c1930273ad460d5a770
|
4
|
+
data.tar.gz: 0c636a47ac05f8428d9e099d952a0b89a512f8e199a3a85a72624c10a76590b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c20dfab19c133d80913716e7be2b20e47958e841e61d7b401f28b73e642358d80ce698d5fd22410ede0bb783114c0e91dfc7a1b4760ebab3738aaba3081275af
|
7
|
+
data.tar.gz: 07664117dfacf9f32fa7e0965199bed938da619b75b313207d702d5ad83ebc2ceacbb76b266e40f3e995114542a110061ad271630a3b007fc2e4f1cbb2bccc58
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.2.
|
1
|
+
2.2.1
|
data/lib/ewelink/api.rb
CHANGED
@@ -12,6 +12,7 @@ module Ewelink
|
|
12
12
|
UUID_NAMESPACE = 'e25750fb-3710-41af-b831-23224f4dd609';
|
13
13
|
VERSION = 8
|
14
14
|
WEB_SOCKET_PING_TOLERANCE_FACTOR = 1.5
|
15
|
+
SWITCH_STATUS_CHANGE_CHECK_TIMEOUT = 2.seconds
|
15
16
|
WEB_SOCKET_WAIT_INTERVAL = 0.2.seconds
|
16
17
|
|
17
18
|
attr_reader :email, :password, :phone_number
|
@@ -163,6 +164,7 @@ module Ewelink
|
|
163
164
|
Ewelink.logger.debug(self.class.name) { "Turning switch #{switch[:uuid].inspect} #{on ? 'on' : 'off'}" }
|
164
165
|
send_to_web_socket(JSON.generate(params))
|
165
166
|
end
|
167
|
+
sleep(SWITCH_STATUS_CHANGE_CHECK_TIMEOUT)
|
166
168
|
switch_on?(switch[:uuid]) # Waiting for switch status update
|
167
169
|
true
|
168
170
|
end
|
@@ -445,6 +447,8 @@ module Ewelink
|
|
445
447
|
sleep(WEB_SOCKET_WAIT_INTERVAL)
|
446
448
|
end
|
447
449
|
block_given? ? yield : true
|
450
|
+
rescue
|
451
|
+
dispose_web_socket
|
448
452
|
end
|
449
453
|
end
|
450
454
|
|