Пример #1
0
 def createSonosDevice(ipAddress=None):
     # Set up the logging before using the Sonos Device
     SocoLogging.enable()
     sonosDevice = None
     if ipAddress is None:
         ipAddress = Settings.getIPAddress()
     if ipAddress != "0.0.0.0":
         sonosDevice = Sonos(ipAddress)
     log("Sonos: IP Address = %s" % ipAddress)
     return sonosDevice
Пример #2
0
 def createSonosDevice(ipAddress=None):
     # Set up the logging before using the Sonos Device
     SocoLogging.enable()
     sonosDevice = None
     if ipAddress is None:
         ipAddress = Settings.getIPAddress()
     if ipAddress != "0.0.0.0":
         sonosDevice = Sonos(ipAddress)
     log("Sonos: IP Address = %s" % ipAddress)
     return sonosDevice
Пример #3
0
 def createSonosDevice(ipAddress=None):
     # Need to make sure that we override the SoCo class with the Sonos one
     config.SOCO_CLASS = Sonos
     # Set up the logging before using the Sonos Device
     SocoLogging.enable()
     sonosDevice = None
     if ipAddress is None:
         ipAddress = Settings.getIPAddress()
     if ipAddress != "0.0.0.0":
         sonosDevice = Sonos(ipAddress)
     log("Sonos: IP Address = %s" % ipAddress)
     return sonosDevice
Пример #4
0
 def createSonosDevice(ipAddress=None):
     # Need to make sure that we override the SoCo class with the Sonos one
     config.SOCO_CLASS = Sonos
     # Set up the logging before using the Sonos Device
     SocoLogging.enable()
     sonosDevice = None
     if ipAddress is None:
         ipAddress = Settings.getIPAddress()
     if ipAddress != "0.0.0.0":
         sonosDevice = Sonos(ipAddress)
     log("Sonos: IP Address = %s" % ipAddress)
     return sonosDevice
Пример #5
0
from settings import SocoLogging

import soco

log('script version %s started' % __version__)


###########################################################################
# This file will perform the lookup of a Sonos speaker and set it in
# the settings
###########################################################################
if __name__ == '__main__':
    log("SonosDiscovery: Searching for Sonos devices")

    # Set up the logging before using the Sonos Device
    SocoLogging.enable()

    # Display the busy icon while searching for files
    xbmc.executebuiltin("ActivateWindow(busydialog)")

    # Use the default method to search for Sonos Devices
    try:
        sonos_devices = soco.discover(timeout=5)
    except:
        log("SonosDiscovery: Exception when getting devices", xbmc.LOGERROR)
        log("SonosDiscovery: %s" % traceback.format_exc(), xbmc.LOGERROR)
        sonos_devices = []

    # If there are multiple network devices, then this may not have picked up
    # the correct network device to broadcast on, so try another way
    if (sonos_devices is None) or (len(sonos_devices) < 1):
Пример #6
0
    def __init__(self):
        # Check if the auto update IP is enabled
        if not Settings.isAutoIpUpdateEnabled():
            return

        # Get the existing zone we are trying to set the IP Address for
        existingZone = Settings.getZoneName()

        # Nothing to do if there is no Zone name set
        if (existingZone is None) or (existingZone == ""):
            return

        # Set up the logging before using the Sonos Device
        SocoLogging.enable()

        try:
            sonos_devices = soco.discover()
        except:
            log("AutoUpdateIPAddress: Exception when getting devices")
            log("AutoUpdateIPAddress: %s" % traceback.format_exc())
            sonos_devices = []

        ipaddresses = []

        # Check each of the devices found
        for device in sonos_devices:
            ip = device.ip_address
            log("AutoUpdateIPAddress: Getting info for IP address %s" % ip)

            playerInfo = None

            # Try and get the player info, if it fails then it is not a valid
            # player and we should continue to the next
            try:
                playerInfo = device.get_speaker_info()
            except:
                log("AutoUpdateIPAddress: IP address %s is not a valid player" % ip)
                log("AutoUpdateIPAddress: %s" % traceback.format_exc())
                continue

            # If player  info was found, then print it out
            if playerInfo is not None:
                # What is the name of the zone that this speaker is in?
                zone_name = playerInfo['zone_name']

                # Check the zone against the ones we are looking for
                if zone_name == existingZone:
                    # There could be multiple IP addressing in the same group
                    # so save them all
                    log("AutoUpdateIPAddress: IP address %s in zone %s" % (ip, existingZone))
                    ipaddresses.append(ip)

        # Check if there is an IP Address to set
        if len(ipaddresses) > 0:
            oldIp = Settings.getIPAddress()
            # Check if we already have a match to the existing IP Address
            matchesExisting = False
            for newIp in ipaddresses:
                if newIp == oldIp:
                    matchesExisting = True
                    break
            # If no match found - then set to the first IP Address
            if not matchesExisting:
                log("AutoUpdateIPAddress: Setting IP address to %s" % ipaddresses[0])
                Settings.setIPAddress(ipaddresses[0])