renstar 0.4.3 → 0.4.4

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: 617260529f9b3d241c8b6f0a4489d9eac7f871a998b9f2e0b42c0ee54e322491
4
- data.tar.gz: 3a7560d9559b8c40272a991449bf6d06916fccd4dbc7914e98a5c58d0c84bdd9
3
+ metadata.gz: e5990b28a9195f211562ebc90e3164440e0a8e401272fa87c7d9a3f0bf8636a4
4
+ data.tar.gz: de3c2bc468511bbc4ce4e57030883996384a83572a70fa649fb882980318a78f
5
5
  SHA512:
6
- metadata.gz: 83fd7c65c7162f8c6c9582a6c8525aa49f14c4c578b56e866581fff21fcfa554afe387396ef399d800993787ec378a1066f3da5cb39ee086a5675e9cc188c119
7
- data.tar.gz: 1bcf749dad62edddb0d6be3b4c8e081eb08bdef1ad4389bc86b372ad7fb6e3bef6d3369764f8c157d19c6b76f1de21b10bd1444c0098edd2e211f30cfb4b9b7b
6
+ metadata.gz: '08cb4e79d6675044dad081a517a5efd9c683b80e593f566459202084c35962f7c37c7f92448cad5d1a957a1753d972de8cbb7ca96e08db0d86716701af1aec6c'
7
+ data.tar.gz: 70a6044088c34b6a0c56d410cc63a1bfee460b6a4c2290846d09f03ed9263504f33c2b1706228e459a2be233de1e0a55439aa6a824b7047d2cc7721950ceb51d
@@ -8,17 +8,8 @@ module Renstar
8
8
  # the network
9
9
  module Discovery
10
10
  # Discovery timeout when searching for thermostats
11
- DEFAULT_TIMEOUT = 3
12
11
  SERVICE = 'venstar:thermostat:ecp'
13
12
 
14
- def search(timeout = DEFAULT_TIMEOUT)
15
- all_thermos = []
16
- ips.each do |ip|
17
- all_thermos << ssdp_search(ip, timeout)
18
- end
19
- all_thermos.flatten
20
- end
21
-
22
13
  private
23
14
 
24
15
  def ips
@@ -28,15 +19,10 @@ module Renstar
28
19
  end
29
20
 
30
21
  # do an SSDP search using the given IP from a found local interface
31
- def ssdp_search(ip, timeout = DEFAULT_TIMEOUT)
22
+ def ssdp_search(ip, timeout = 5)
32
23
  puts "Searching subnet associated with #{ip.ip_address}"
33
24
  ssdp = SSDP::Consumer.new({ bind: ip.ip_address })
34
25
  thermos = ssdp.search(service: SERVICE, timeout: timeout)
35
- thermos.map do |thermo|
36
- location = thermo[:params]['Location']
37
- usn = thermo[:params]['USN']
38
- Renstar::Thermostat.new(location, usn)
39
- end
40
26
  end
41
27
  end
42
28
  end
@@ -30,6 +30,18 @@ module Renstar
30
30
  @cached_info = info
31
31
  end
32
32
 
33
+ def self.search(timeout = 3)
34
+ all_thermos = []
35
+ ips.each do |ip|
36
+ all_thermos << ssdp_search(ip, timeout)
37
+ end
38
+ all_thermos.flatten.map do |thermo|
39
+ location = thermo[:params]['Location']
40
+ usn = thermo[:params]['USN']
41
+ Renstar::Thermostat.new(location, usn)
42
+ end
43
+ end
44
+
33
45
  def update
34
46
  @cache_timestamp = Time.now
35
47
  @cached_info = info
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Renstar
4
- VERSION = '0.4.3'
4
+ VERSION = '0.4.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renstar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Rodrigues