def update_device_list(self, sessions):
if sessions is None:<EOL><INDENT>_LOGGER.error('<STR_LIT>')<EOL>return<EOL><DEDENT>new_devices = []<EOL>active_devices = []<EOL>dev_update = False<EOL>for device in sessions:<EOL><INDENT>dev_name = '<STR_LIT>'.format(device['<STR_LIT>'], device['<STR_LIT>'])<EOL>try:<EOL><INDENT>_LOGGER.debug('<STR_LIT>',<EOL>dev_name, device['<STR_LIT>']['<STR_LIT>'],<EOL>device['<STR_LIT>']['<STR_LIT>'])<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT>active_devices.append(dev_name)<EOL>if dev_name not in self._devices anddevice['<STR_LIT>'] != str(self._api_id):<EOL><INDENT>_LOGGER.debug('<STR_LIT>',<EOL>dev_name)<EOL>new = EmbyDevice(device, self)<EOL>self._devices[dev_name] = new<EOL>new_devices.append(new)<EOL><DEDENT>elif device['<STR_LIT>'] != str(self._api_id):<EOL><INDENT>if not self._devices[dev_name].is_active:<EOL><INDENT>dev_update = True<EOL><DEDENT>do_update = self.update_check(<EOL>self._devices[dev_name], device)<EOL>self._devices[dev_name].update_data(device)<EOL>self._devices[dev_name].set_active(True)<EOL>if dev_update:<EOL><INDENT>self._do_new_devices_callback(<NUM_LIT:0>)<EOL>dev_update = False<EOL><DEDENT>if do_update:<EOL><INDENT>self._do_update_callback(dev_name)<EOL><DEDENT><DEDENT><DEDENT>for dev_id in self._devices:<EOL><INDENT>if dev_id not in active_devices:<EOL><INDENT>if self._devices[dev_id].is_active:<EOL><INDENT>self._devices[dev_id].set_active(False)<EOL>self._do_update_callback(dev_id)<EOL>self._do_stale_devices_callback(dev_id)<EOL><DEDENT><DEDENT><DEDENT>if new_devices:<EOL><INDENT>self._do_new_devices_callback(<NUM_LIT:0>)<EOL><DEDENT>
Update device list.