'Update state and attributes.'

def update(self):

    self.refresh_spotify_instance()
    player_devices = self._player.devices()
    if (player_devices is not None):
        devices = player_devices.get('devices')
        if (devices is not None):
            old_devices = self._devices
            self._devices = {self._aliases.get(device.get('id'), device.get('name')): device.get('id') for device in devices}
            device_diff = {name: id for (name, id) in self._devices.items() if (old_devices.get(name, None) is None)}
            if device_diff:
                _LOGGER.info('New    Devices:    %s', str(device_diff))
    current = self._player.current_playback()
    if (current is None):
        self._state = STATE_IDLE
        return
    item = current.get('item')
    if item:
        self._album = item.get('album').get('name')
        self._title = item.get('name')
        self._artist = ',    '.join([artist.get('name') for artist in item.get('artists')])
        self._uri = current.get('uri')
        self._image_url = item.get('album').get('images')[0].get('url')
    self._state = STATE_PAUSED
    if current.get('is_playing'):
        self._state = STATE_PLAYING
    self._shuffle = current.get('shuffle_state')
    device = current.get('device')
    if (device is None):
        self._state = STATE_IDLE
    else:
        if device.get('volume_percent'):
            self._volume = (device.get('volume_percent') / 100)
        if device.get('name'):
            self._current_device = device.get('name')
