List filenames in a folder into a sensor entity, is it possible?

Hi all

I need to get the filenamesin a folder and put them into a sensor entity?

The folder I need to check is within the /config/www folder

Is it possible?

I’ve tried with appdaemon, creating a python script in /confic/appdaemon/apps/file_list.py as below

import os
import appdaemon.plugins.hass.hassapi as hass

class ListFiles(hass.Hass):
    def initialize(self):
        self.run_in(self.list_files, 0)

    def list_files(self, kwargs):
        folder_path = "/config/www/llmvision"
        try:
            files = os.listdir(folder_path)
            self.log(f"Files in {folder_path}: {files}")
            self.set_state("sensor.file_list_llmvision", state=", ".join(files))
        except Exception as e:
            self.log(f"Error listing files: {e}")

but it does not create the sensor and I don’t understand if it’s running?

Is this the only way or there is another one?
What can I check?

Thanks