TarheelGrad1998 / files

Custom Component for Home Assistant that reads a list of files from a directory into a sensor. Pre requisite for the Gallery Card.
10 stars 8 forks source link

Limitations about files? #9

Open Bierchermuesli opened 3 years ago

Bierchermuesli commented 3 years ago

I have a folder with multiple pictures per day....

path: /config/www/timelapses/
filter: **/*.jpg
number_of_files: 10936
bytes: 340396584
fileList: /config/www/timelapses/20210303/202103031954.jpg, / ....(list of 10k files)

State Engine works so far, just a bit slow... :-)

recorder/mysql has some limitations - an recorder exclusion could help but I guess my Use case is beyond what this cpmponent was planned for.


home-assistant    | 2021-04-14 21:46:29 ERROR (Recorder) [homeassistant.components.recorder] Unexpected error saving events: (MySQLdb._exceptions.DataError) (1406, "Data too long for column 'attributes' at row 1")
home-assistant    | [SQL: INSERT INTO states (domain, entity_id, state, attributes, event_id, last_changed, last_updated, created, old_state_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)]
home-assistant    | [parameters: ('sensor', 'sensor.balkon_jpg', '340.4', '{"path": "/config/www/timelapses/", "filter": "**/*.jpg", "number_of_files": 10936, "bytes": 340396584, "fileList": ["/config/www/timelapses/20210303 ... (568608 characters truncated) ... ses/20210414/202104142013.jpg"], "sort": "date", "recursive": true, "unit_of_measurement": "MB", "friendly_name": "balkon-jpg", "icon": "mdi:folder"}', 13928857, datetime.datetime(2021, 4, 14, 19, 46, 26, 686915, tzinfo=datetime.timezone.utc), datetime.datetime(2021, 4, 14, 19, 46, 26, 686915, tzinfo=datetime.timezone.utc), datetime.datetime(2021, 4, 14, 19, 46, 26, 686915, tzinfo=datetime.timezone.utc), None)]
home-assistant    | (Background on this error at: http://sqlalche.me/e/13/9h9h)

Can the fileList attribut removed or shortened? or is it madatory for the Frontend component?

TarheelGrad1998 commented 3 years ago

Wow, yes, you broke me. By far. :)

The fileList attribute is what feeds the front end Gallery card, to know what files to display. So it is mandatory.

I have a maximum files config for the front end but not on the files component...sounds like from your use case I should add one here as well.

In the meantime you could try the Media Source configuration by adding your folder as a media source in HA, then selecting that for the Gallery card along with a maximum file config. It might give you problems as well though fetching a list of 10k files via the API.

Bierchermuesli commented 3 years ago

Yeah, my case is probably a bit stupid. I would never check all the files.

Im going to process the timeleapse gif/mpeg and keep the last 10 in the folder. Anyway a maximum attribute would make sense ;-)

TarheelGrad1998 commented 3 years ago

That is probably the best solution all around. It should work that way and be much faster as well.

I'll keep this issue open and add the attribute when I have time.