ewelink 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.mdown +5 -0
  3. data/VERSION +1 -1
  4. data/lib/ewelink/api.rb +7 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45f904d5e72d0038360340adc26dd7eb963f664804b43eee8235ee02d48f60ff
4
- data.tar.gz: 98ee94c2d9187ea17250c3f32c1932f8c0df8a2123c341a47159c32e2aec66e9
3
+ metadata.gz: c9b83156bba48622088845d22bd8fc3b559d6e8732acf4664ba35886c6c19d35
4
+ data.tar.gz: d69303e93b04b56fd713fc27220d15c4ab66ca767190a289d6440932dc468532
5
5
  SHA512:
6
- metadata.gz: 42977ef17b87c9c6710973968ca739d642108d6595861a870090ef13fbe5332b7ff99fba0dc8444e8022dfba065f4334426daf2dc423ed08314b3939cc41e69a
7
- data.tar.gz: 4fa2068348c252aecfa1f0d55f91013a17658a3403fa7813208f34f027757b2459181323aae9a9d8c71c915ac8c83e881150c4eacee77ed85832b1adaeadb451
6
+ metadata.gz: fa3fd8b8a36ad7e4570db2941ebdffc1d134106ea40ce93866eaebe7b81a4cc0a35920f5366a48c0a9141476101cc03be42adf244b15bcf98eeec64b0e77a312
7
+ data.tar.gz: d98f59eaec9c582dd0627a52a392c45e98e351676b69d36f081df4ec819153bd32e340ced77440152c674d58013f413d8e42a5e86a50f65d57efce5782f26943
@@ -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.0
1
+ 3.2.0
@@ -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.1.0
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-12 00:00:00.000000000 Z
11
+ date: 2020-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport