robmarkcole / HASS-Sighthound

Beta features for Home Assistant Sighthound integration
https://www.home-assistant.io/integrations/sighthound/
MIT License
34 stars 10 forks source link

image_processing.file_saved event never fires #11

Closed bradyn12 closed 4 years ago

bradyn12 commented 4 years ago

I'm using this custom integration through HACS. I'm running Home Assistant on Docker (version 0.105). I'm able to run image_processing.scan successfully and it saves the processed image to my www folder. The person_detected' event fires but thefile_saved` event is never fired. So I'm struggling to use this in an automation to send the image in a notification. Let me know what additional information is needed to help debug this error.

robmarkcole commented 4 years ago

Hmm are there any relevant errors or warnings? Please set log level to debug

bradyn12 commented 4 years ago

I set logger to debug for both "custom_components.sighthound" and "homeassistant.components.image_processing" and there weren't any errors. I dug into the source code and realized this "bug" was just a user error/misunderstanding. The file_saved event only gets triggered when "save_timestamped_file" is set to true. I expected that event to work when it was both true and false as a sort of callback to ensure the image was saved before running an automation. Looking at the source code, I see that the image is saved before the "person_detected" event is called in the scenario where "save_timestamped_file" is set to false.

Maybe this little nuance should be mentioned in the README to help clarify for future users? The "file_saved" event is only shown in the example automation without any further explanation.

robmarkcole commented 4 years ago

Hi I added this feature in the latest release. Looking again at the code I remember the headaches I had previously with events being fired before files had actually been written to disk, I am not sure if this is adequately resolved. Let me know how you get on? Cheers