code: def update_device_list(self, sessions):
          if sessions is None:
              _LOGGER.error('Error updating Emby devices.')
              return
          new_devices = []
          active_devices = []
          dev_update = False
          for device in sessions:
              dev_name = '{}.{}'.format(device['DeviceId'], device['Client'])
              try:
                  _LOGGER.debug('Session msg on %s of type: %s, themeflag: %s',
                                dev_name, device['NowPlayingItem']['Type'],
                                device['NowPlayingItem']['IsThemeMedia'])
              except KeyError:
                  pass
              active_devices.append(dev_name)
              if dev_name not in self._devices and \
                      device['DeviceId'] != str(self._api_id):
                  _LOGGER.debug('New Emby DeviceID: %s. Adding to device list.',
                                dev_name)
                  new = EmbyDevice(device, self)
                  self._devices[dev_name] = new
                  new_devices.append(new)
              elif device['DeviceId'] != str(self._api_id):
                  if not self._devices[dev_name].is_active:
                      dev_update = True
                  do_update = self.update_check(
                      self._devices[dev_name], device)
                  self._devices[dev_name].update_data(device)
                  self._devices[dev_name].set_active(True)
                  if dev_update:
                      self._do_new_devices_callback(0)
                      dev_update = False
                  if do_update:
                      self._do_update_callback(dev_name)
          for dev_id in self._devices:
              if dev_id not in active_devices:
                  if self._devices[dev_id].is_active:
                      self._devices[dev_id].set_active(False)
                      self._do_update_callback(dev_id)
                      self._do_stale_devices_callback(dev_id)
          if new_devices:
              self._do_new_devices_callback(0)