Quite a lot of applications create temporary files during normal operation, this could be causing all the triggers. You could us the patterns
variable to try limit the number of triggers
How dāyou mean? isnāt the trigger caused by the file referred to as ātrigger.event.data.pathā? If so, surely any temporary file would be the one that is sent, not the one I copied?
I tried to add a shell command straight after in the automation to delete the file. This resulted in multiple copies of half a file coming through on Telegram (bottom half of image blank) and then an error in the logs saying it couldnāt send because the file didnāt exist.
Oh I think I got your issue confused with another on this thread. You can disable automations temporarily (there is a thread on the forums somehwere), but my experience is that getting the timing just right is quite tricky
Should imagine it is. It still doesnāt explain why I get the same image multiple times though; the fact is that the jpg folder watcher is looking for gets created once, so why should I get repeated triggers?!
Something not right.
Just tried the āModifiedā event type and if I rename a file thatās already in there I get one message, so expected behaviour. If I leave it set to modified and upload a file though the same problem occurs.
Tried Samba, FTP connection from PC and from camera and still getting multiple triggers. Strange thing is thereās no pattern to how many triggers I get. Sometime 4-5, others a few hundred.
I had similar problem due to ātempā file triggering before complete file was generated.
I just added delay of couple of seconds to my automation.
Got it working! Turns out itās very funny about the way the YAML is laid out.
Swapping:
trigger:
- event_data:
event_data:
event_type: created
event_type: folder_watcher
platform: event
for:
trigger:
platform: event
event_type: folder_watcher
event_data:
event_type: created
Did the trick. It turns out that if you donāt specify an event type to trigger on it fires on ANY event. Whilst I specified a type originally, my YAML wasnāt quite right so the event type Iād specified was ignored and default behaviour prevailed.
Where did you get the first version from? The second is in the docs
I know. I copied from the docs in the first place but dipped in with the GUI to make a couple of quick changes to the action. The GUI rearranged it all as it does which broke it. I didnāt think it would matter but it obviously does!
Iād like to check something regarding the documentation that isnāt quite clear to me: Is the folder
option relative to the HA installationās path, or is it an absolute path? As an example, if I set - folder: /tmp/
and /tmp/
is world readable, should/would it work?
And for me relevant close to this is if itās possible to watch a folder outside HA, like on a usb disk on a PC or NAS via Samba and smb: function?
cannot watch external locations, although you could install home assistant on the external location and use it
Thats an idea of course. Thanks!!
I did find this software https://directorymonitor.com/ so I will try that first
Sounded interesting until I saw $159 USD for 1 machine license
They can for sure keep track of directories (even in the free version) but I have a need to keep track of a COPY being ready and that they cant do. Only create and the other things, but not Copy.
@robmarkcole Looks like a cool component, but Iām getting errors when setting this up. The config comes up clean when I check config via Server Controls.
Here are the log errors and my configs:
Logs:
2020-09-08 10:09:09 ERROR (SyncWorker_2) [homeassistant.components.folder_watcher] folder /share is not valid or allowed
2020-09-08 10:09:10 INFO (MainThread) [homeassistant.setup] Setup of domain folder_watcher took 0.6 seconds
2020-09-08 10:09:10 ERROR (MainThread) [homeassistant.setup] Setup failed for folder_watcher: Integration failed to initialize.
"/share" directory added to [allowlist_external_dirs:
homeassistant:
name: Home
latitude: ##.######
longitude: -##.######
elevation: 72
unit_system: imperial
time_zone: America/New York
external_url: "https://########################.ui.nabu.casa/lovelace/home"
internal_url: "http://###.###.#.###:8123"
allowlist_external_dirs:
- /share
Basic config:
folder_watcher:
- folder: /share
Ah dockerā¦ The error is folder /share is not valid or allowed
Recommend some experimentation
@robmarkcole ok - so this folder is located at //192.168.1.237/share
(my HA IP), along with my /config folder and a few others I canāt recall - /add ons I think?. I have swapped out /share with /config and get the same results - no dice. What sort of experimentation would you recommend?
I think the issue is that /share
is not accessible to the home assistant user. Better to create a subdirectory in /config and
watch that as per the docs example. So you will have config like:
folder_watcher:
- folder: /config/my_watched_dir
@robmarkcole Unfortunately, no dice
I updated the config, restarted HA from the UI, and for good measure, I also restarted the VM to make sure the allowlist_external_dirs
gets updated, and I still get the same error in the logs:
2020-09-09 15:21:33 ERROR (SyncWorker_38) [homeassistant.components.folder_watcher] folder /config/folder_watcher is not valid or allowed
2020-09-09 15:21:34 INFO (MainThread) [homeassistant.setup] Setup of domain folder_watcher took 0.1 seconds
2020-09-09 15:21:34 ERROR (MainThread) [homeassistant.setup] Setup failed for folder_watcher: Integration failed to initialize.