Best practise for reacting to a transfered file #22380
-
When my doorbell rings, I capture a picture and send it via ftp to my Lanbon L8. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
If by "ftp" you mean the FTP server you can enable with the "UFSFTP" command, that does not provide any signals you can pick up, when a file has been stored. Hence you could start polling for the file (with reasonably short intervals) after getting the MQTT message. Or you could have the doorbell end publish another message after having transferred the file. If you instead use the Berry example FTP server, you could easily modify that to do something when a file was received and stored. https://github.com/arendst/Tasmota/blob/development/tasmota/berry/drivers/ftp.be |
Beta Was this translation helpful? Give feedback.
-
Thank you for the input. I did not know about the Berry FTP server and perhaps that is a promissing way. What you called polling was the way I tried but did not succeed. .
def t() print("warte auf Bild") end
while path.exists('Door.png')!=true tasmota.set_timer(100,t) end
. This code did not work. There must be some fault. |
Beta Was this translation helpful? Give feedback.
-
That code is blocking, meaning that you cannot do anything (including transferring files) while it runs. It will not wait 100 ms between checks, but it will schedule a shitload of those timers, which does not exactly help the situation. Something like this works better, doing the check inside the periodic checking function
Also illustrates how to proceed with further code when the file is found, and a sanity check to prevent infinite polling. |
Beta Was this translation helpful? Give feedback.
That code is blocking, meaning that you cannot do anything (including transferring files) while it runs. It will not wait 100 ms between checks, but it will schedule a shitload of those timers, which does not exactly help the situation.
Something like this works better, doing the check inside the periodic checking function
Also illustrates how to proceed with further code when the file is found, and a sanity check to prevent infin…