platypush/plugins/music/snapcast/__init__.py
def volume(self, client, volume=None, delta=None, mute=None, host=None,
               port=None):
        """
        Set the volume of a connected client

        :param client: Client name or ID
        :type client: str

        :param volume: Absolute volume to set between 0 and 100
        :type volume: int

        :param delta: Relative volume change in percentage (e.g. +10 or -10)
        :type delta: int

        :param mute: Set to true or false if you want to toggle the muted status
        :type mute: bool

        :param host: Snapcast server (default: default configured host)
        :type host: str

        :param port: Snapcast server port (default: default configured port)
        :type port: int
        """

        if volume is None and delta is None and mute is None:
            raise RuntimeError('Please specify either an absolute volume or ' +
                               'relative delta')

        sock = None

        try:
            sock = self._connect(host or self.host, port or self.port)
            request = {
                'id': self._get_req_id(),
                'jsonrpc': '2.0',
                'method': 'Client.SetVolume',
                'params': {}
            }

            client = self._get_client(sock, client)
            cur_volume = int(client['config']['volume']['percent'])
            cur_mute = bool(client['config']['volume']['muted'])

            if volume is not None:
                volume = int(volume)
            elif delta is not None:
                volume = cur_volume + int(delta)

            if volume is not None:
                if volume > 100: volume = 100
                if volume < 0: volume = 0
            else:
                volume = cur_volume

            if mute is None:
                mute = cur_mute

            request['params']['id'] = client['id']
            request['params']['volume'] = {}
            request['params']['volume']['percent'] = volume
            request['params']['volume']['muted'] = mute
            # noinspection PyTypeChecker
            self._send(sock, request)
            return self._recv(sock)
        finally:
            try:
                sock.close()
            except Exception as e:
                self.logger.warning('Error on socket close', e)

        Set the volume of a connected client

        :param client: Client name or ID
        :type client: str

        :param volume: Absolute volume to set between 0 and 100
        :type volume: int

        :param delta: Relative volume change in percentage (e.g. +10 or -10)
        :type delta: int

        :param mute: Set to true or false if you want to toggle the muted status
        :type mute: bool

        :param host: Snapcast server (default: default configured host)
        :type host: str

        :param port: Snapcast server port (default: default configured port)
        :type port: int
        
Set the volume of a connected client
Set the volume of a connected client
def volume(self, client, volume=None, delta=None, mute=None, host=None,
               port=None):
        if volume is None and delta is None and mute is None:
            raise RuntimeError('Please specify either an absolute volume or ' +
                               'relative delta')
        sock = None
        try:
            sock = self._connect(host or self.host, port or self.port)
            request = {
                'id': self._get_req_id(),
                'jsonrpc': '2.0',
                'method': 'Client.SetVolume',
                'params': {}
            }
            client = self._get_client(sock, client)
            cur_volume = int(client['config']['volume']['percent'])
            cur_mute = bool(client['config']['volume']['muted'])
            if volume is not None:
                volume = int(volume)
            elif delta is not None:
                volume = cur_volume + int(delta)
            if volume is not None:
                if volume > 100: volume = 100
                if volume < 0: volume = 0
            else:
                volume = cur_volume
            if mute is None:
                mute = cur_mute
            request['params']['id'] = client['id']
            request['params']['volume'] = {}
            request['params']['volume']['percent'] = volume
            request['params']['volume']['muted'] = mute
            self._send(sock, request)
            return self._recv(sock)
        finally:
            try:
                sock.close()
            except Exception as e:
                self.logger.warning('Error on socket close', e)
def volume ( self , client , volume = None , delta = None , mute = None , host = None , port = None ) : if volume is None and delta is None and mute is None : raise RuntimeError ( 'Please specify either an absolute volume or ' + 'relative delta' ) sock = None try : sock = self . _connect ( host or self . host , port or self . port ) request = { 'id' : self . _get_req_id ( ) , 'jsonrpc' : '2.0' , 'method' : 'Client.SetVolume' , 'params' : { } } client = self . _get_client ( sock , client ) cur_volume = int ( client [ 'config' ] [ 'volume' ] [ 'percent' ] ) cur_mute = bool ( client [ 'config' ] [ 'volume' ] [ 'muted' ] ) if volume is not None : volume = int ( volume ) elif delta is not None : volume = cur_volume + int ( delta ) if volume is not None : if volume > 100 : volume = 100 if volume < 0 : volume = 0 else : volume = cur_volume if mute is None : mute = cur_mute request [ 'params' ] [ 'id' ] = client [ 'id' ] request [ 'params' ] [ 'volume' ] = { } request [ 'params' ] [ 'volume' ] [ 'percent' ] = volume request [ 'params' ] [ 'volume' ] [ 'muted' ] = mute self . _send ( sock , request ) return self . _recv ( sock ) finally : try : sock . close ( ) except Exception as e : self . logger . warning ( 'Error on socket close' , e )
Set the volume of a connected client
Set the volume of a connected client
"""
        Set the volume of a connected client

        :param client: Client name or ID
        :type client: str

        :param volume: Absolute volume to set between 0 and 100
        :type volume: int

        :param delta: Relative volume change in percentage (e.g. +10 or -10)
        :type delta: int

        :param mute: Set to true or false if you want to toggle the muted status
        :type mute: bool

        :param host: Snapcast server (default: default configured host)
        :type host: str

        :param port: Snapcast server port (default: default configured port)
        :type port: int
        """ # noinspection PyTypeChecker
self
client
Client name or ID
Client name or ID
volume
Absolute volume to set between 0 and 100
Absolute volume to set between 0 and 100
delta
Relative volume change in percentage
Relative volume change in percentage
mute
Set to true or false if you want to toggle the muted status
Set to true or false if you want to toggle the muted status
host
Snapcast server (default: default configured host)
Snapcast server ( default : default configured host )
port
Snapcast server port (default: default configured port)
Snapcast server port ( default : default configured port )