'Get the latest entry from a file and updates the state.'

def update(self):

    try:
        with open(self._file_path, 'r', encoding='utf-8') as file_data:
            for line in file_data:
                data = line
            data = data.strip()
    except (IndexError, FileNotFoundError, IsADirectoryError, UnboundLocalError):
        _LOGGER.warning('File    or    data    not    present    at    the    moment:    %s', os.path.basename(self._file_path))
        return
    if (self._val_tpl is not None):
        self._state = self._val_tpl.async_render_with_possible_json_value(data, None)
    else:
        self._state = data
