Module: Sonos::Endpoint::Device

Included in:
Device::Speaker
Defined in:
lib/sonos/endpoint/device.rb

Constant Summary collapse

DEVICE_ENDPOINT =
'/DeviceProperties/Control'
DEVICE_XMLNS =
'urn:schemas-upnp-org:service:DeviceProperties:1'

Instance Method Summary collapse

Instance Method Details

#create_pair_with(right) ⇒ Object

Create a stereo pair of two speakers. This does not take into account which type of players support bonding. Currently only S1/S3 (play:1/play:3) support this but future players may gain this abbility too. The speaker on which this method is called is assumed to be the left speaker of the pair.

Parameters:



25
26
27
28
29
# File 'lib/sonos/endpoint/device.rb', line 25

def create_pair_with(right)
  left = self.uid.sub!('uuid:', '')
  right = right.uid.sub!('uuid:', '')
  parse_response = send_bonding_message('AddBondedZones', "#{left}:LF,LF;#{right}:RF,RF")
end

#separate_pairObject



31
32
33
# File 'lib/sonos/endpoint/device.rb', line 31

def separate_pair
  parse_response = send_bonding_message('RemoveBondedZones', '')
end

#status_light_enabled=(enabled) ⇒ Object

Turn the white status light on or off

Parameters:

  • True (Boolean)

    to turn on the light. False to turn off the light.



15
16
17
# File 'lib/sonos/endpoint/device.rb', line 15

def status_light_enabled=(enabled)
  parse_response send_device_message('SetLEDState', enabled ? 'On' : 'Off')
end

#status_light_enabled?Boolean

Retrieve the status light state; true if on, false otherwise.

Returns:

  • (Boolean)


6
7
8
9
10
11
# File 'lib/sonos/endpoint/device.rb', line 6

def status_light_enabled?
  response = send_device_message('GetLEDState', '')
  body = response.body[:get_led_state_response]

  body[:current_led_state] == 'On' ? true : false
end