OctoPrint-Telegram icon indicating copy to clipboard operation
OctoPrint-Telegram copied to clipboard

[Feature Request] Add option for a delay between pre-image-action & screenshot

Open farfalleflickan opened this issue 3 years ago • 8 comments

Hi!

I've configured the image-actions to turn on the 'torch' mode on my led string, which is managed by WS281x_LED_Status. The only problem is that most of the time the Telegram plugins reacts too fast, so the picture sent doesn't have the leds turned on.

So I was thinking if it would be possible to add an option to add a delay to the image taking after pre-image-action and before post-image-action.

Thanks!

farfalleflickan avatar May 07 '21 20:05 farfalleflickan

I have the same general problem: I am using a M150 gcode for the pre image action and the Telegram plugins send the picture well before the lights have turned on :(

My setup is based on klipper and monochromatic LED strips connected to a SKR. I believe that adding a delay option should be enough for our cases and many similar ones, if I'm not mistaken.

alexbarcelo avatar May 28 '21 11:05 alexbarcelo

Hi ,

what I fear by doing that we create some problem for octoprint as well and then the print could be bad.

I'll try to test it still

giloser avatar Aug 11 '21 12:08 giloser

Thanks for replying, I hadn't thought about that...

May I suggest threading or OctoPrint's built-in?

farfalleflickan avatar Aug 11 '21 13:08 farfalleflickan

Hi, i have read this discussion and i could solve this issue as following with the help of API-Documentation of the TP-Link Plugin:

I changed the pre-Image action to System Command and inserted the command

curl -s -H "Content-Type: application/json" -H "X-Api-Key: YOUR_API_KEY" -X POST -d '{ "command":"turnOn", "ip":"<ip of smartplug in settings>" }' http://YOUR_OCTOPRINT_SERVER/api/plugin/tplinksmartplug

for turn on the light with the global api-key which could be find in the octoprint settings under "API" added a sleep command with

&& sleep 5

and achieved the delay for taking the picture.

I do not know if this will help for your specific situation but maybe you get a idea how to get things working.

ManeLippert avatar Dec 29 '21 20:12 ManeLippert

~~@ManeLippert if I'm not mistaken, this solution is effectively pausing the printing for 5 seconds. Which may be suboptimal regarding print time and quality.~~

Hopefully, a delay option may be able to execute a command, and some seconds later (without pausing or affecting the print) proceed to take a screenshot. This way the system gives enough time to the machinery (in my case it is klipper buffers, but OP has the same problem with the WS2812 LEDs) to react.

~~Correct me if I'm wrong.~~ I'm wrong

alexbarcelo avatar Dec 29 '21 23:12 alexbarcelo

@alexbarcelo I have tested it before commenting my solution and so far the printer (Ender3 V2) does not stop for 5 seconds. Because it is a shell command and not a command in g-code i think the 5 seconds delay only affects the next routine of the telegram-plugin which would be taking the image of your print.

But I will have an eye on my next prints and if i notice a delay, i will let you know.

ManeLippert avatar Dec 29 '21 23:12 ManeLippert

@alexbarcelo as expected no delay in printing when sending commands for the image via telegram. Everything working like intended. :)

ManeLippert avatar Dec 30 '21 13:12 ManeLippert

hi

check version https://github.com/giloser/OctoPrint-Telegram/archive/refs/heads/master.zip it's planned but not released yet

giloser avatar Dec 30 '21 13:12 giloser