Class: WemoDevice::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/wemo_device/device.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Device

Returns a new instance of Device.



20
21
22
# File 'lib/wemo_device/device.rb', line 20

def initialize(response)
  @response = response
end

Class Method Details

.lookupObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/wemo_device/device.rb', line 8

def lookup
  # Wemo devices are responding only when search target is the URN.
  # `ssdp:all` and other search target doesn't work.
  SSDP.new.lookup(URN, 3).select do |response|
    # There are many devices that ignores `ST`, like Philips Hue.
    response.search_target == URN
  end.map do |response|
    Device.new(response)
  end
end

Instance Method Details

#descriptionObject



32
33
34
# File 'lib/wemo_device/device.rb', line 32

def description
  @description ||= Description.new(@response.location)
end

#locationObject



28
29
30
# File 'lib/wemo_device/device.rb', line 28

def location
  @response.location
end

#unique_service_nameObject



24
25
26
# File 'lib/wemo_device/device.rb', line 24

def unique_service_name
  @response.unique_service_name
end