bosesoundtouchapi.soundtouchdiscovery
This class contains methods used to dicover SoundTouch devices on a local network. The ZeroConf (aka MDNS, etc) service is used to detect devices, and adds them to a device list as they are discovered.
Click the Sample Code links in the individual methods for sample code examples.
Initializes a new instance of the class.
Arguments:
- areDevicesVerified (bool): True to create a
SoundTouchDevice
instance for discovered devices, which verifies that the device can be accessed by aSoundTouchClient
instance and basic information obtained about its capabilities; otherwise, False to just identify the IPV4 Address, Port, and Device Name.
Default is False. - printToConsole (bool): True to print discovered device information to the console as the devices are discovered; otherwise, False to not print anything to the console. Default is False.
Specify False for the areDevicesVerified
argument if you want to speed up
device discovery, as it takes extra time to verify device connections as they
are discovered.
Determines if a SoundTouchDevice
object is created for devices that are
discovered. This property is set by what is passed to the class constructor.
If False, then the VerifiedDevices
property will be empty;
If True, then the VerifiedDevices
property will contain a SoundTouchDevice
instance for each device that was detected as part of the discovery process.
A dictionary of discovered device names that were detected by the discovery process.
Dictionary keys will be in the form of "address:port", where "address" is the device ipv4 address and the "port" is the ipv4 port number the SoundTouch web-services api is listening on.
Dictionary values will be the device names (e.g. "SoundTouch 10", etc.). This will match the name of the device as displayed in the SoundTouch App.
A dictionary of discovered SoundTouchDevice
instances that were detected
on the network.
This property is only populated if the AreDevicesVerified
property is True.
Dictionary keys will be in the form of "address:port", where "address" is the device ipv4 address and the "port" is the ipv4 port number the SoundTouch web-services api is listening on.
Dictionary values will be SoundTouchDevice
instances that represent the discovered
device.
Discover SoundTouch devices on the local network via the ZeroConf (aka MDNS) service.
Arguments:
- timeout (int): Maximum amount of time to wait (in seconds) for the
discovery to complete.
Default is 5 seconds.
Returns:
A dictionary of discovered
SoundTouchDevice
objects.
Sample Code
# our package imports.
from bosesoundtouchapi import *
try:
print("Test Starting\n")
# create a new instance of the discovery class.
# we will verify device connections, as well as print device details
# to the console as they are discovered.
discovery:SoundTouchDiscovery = SoundTouchDiscovery(True, printToConsole=True)
# discover SoundTouch devices on the network, waiting up to
# 5 seconds for all devices to be discovered.
discovery.DiscoverDevices(timeout=5)
# print all discovered devices.
print("\n%s" % (discovery.ToString(True)))
except Exception as ex:
print(str(ex))
raise
finally:
print("\nTests Completed")