Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Adds folder_watcher component #12918
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<4885>
Example entry for
Sorry about those previous comments, a few of them do not apply since this a component and not a platform. Here's a few thoughts I have on this:
I think we should think about use cases for this component for our other decisions.
You implemented some file filtering options, I understand the need for them, but we should think about how they should be done.
File filters we could use:
Platform vs. Component
At first I thought this was going to be a rewrite of the folder sensor. Honestly, I think it would kind of make for sense there. Maybe there already was a discussion on this that I missed/can't remember. Some thoughts:
@OttoWinter thanks for your detailed comments.
Mine is to monitor a folder where a motion activate camera is saving time-stamped files. I will use an automation to watch for new images then send them image processing. The same principle applies to services that save .txt or other files. If people want to watch for individual files, they can specify the file_name as a filter in their automation.
I agree this is necessary. I've implemented the PatternMatchingEventHandler class which uses glob.
Platform vs. Component
There was indeed an earlier conversation about this. A sensor alone might miss files being added if two were added at the same time, therefore events are necessary. There is so much overlap with the folder sensor I am beginning to think this PR should be integrated to it. This would improve the folder sensor as the number of files it displays can be updated immediately, rather than having a scan_interval of 30 seconds. The folder sensor could then have an attribute for the last X events, but the docs make clear that people should use events for automations. Is that too complicated? @balloob @dgomes
Re imports, @OttoWinter your suggestion works :-)
In my tests if I have:
python 3.5.3 test passes but python 3.6 fails, but if I have:
python 3.6 test passes but python 3.5.3 fails.
UPDATE - this passes 3.5.3 and 3.6
Travis is seriously driving me mad :-0
The only test now failing states