'Get the latest data from the device.'

def update(self):

    temp = (-99)
    if self._device_file.startswith(DEFAULT_MOUNT_DIR):
        lines = self._read_temp_raw()
        while (lines[0].strip()[(-3):] != 'YES'):
            time.sleep(0.2)
            lines = self._read_temp_raw()
        equals_pos = lines[1].find('t=')
        if (equals_pos != (-1)):
            temp_string = lines[1][(equals_pos + 2):]
            temp = round((float(temp_string) / 1000.0), 1)
    else:
        try:
            ds_device_file = open(self._device_file, 'r')
            temp_read = ds_device_file.readlines()
            ds_device_file.close()
            if (len(temp_read) == 1):
                temp = round(float(temp_read[0]), 1)
        except ValueError:
            _LOGGER.warning('Invalid    temperature    value    read    from    %s', self._device_file)
        except FileNotFoundError:
            _LOGGER.warning('Cannot    read    from    sensor:    %s', self._device_file)
    if ((temp < (-55)) or (temp > 125)):
        return
    self._state = temp
