Need help with plugin creation for a timelapse

All of this works in my current fork. You just need to add the delay input to the settings template.

wow really ... going there asap

you are rigth i did as my folder in my pc has messed up to an extent that i had currept file. so i have just deletec the ones in the rep and added the new ones that are working ( trigger + delay + snapshot + store file ) the only this bad in the repo was that i was unable to reade and store the config.

Hello jneilliii

sorry for the late reply.
i did take a look to your code and made some changes to my current working ( part of it) but i am still unable to make the settings template be populated by whatever pin is being used in the init.py

i have updated my git with the latest files, can you you point out where i have Fu§§£@§@ up?
https://github.com/xmodpt/test/tree/main

i also have added a log line to check what gpio is beeing used and the output in octoprint.log is

2024-03-02 16:49:02,405 - octoprint.plugins.sla_timelapse - INFO - GPIO Pin retrieved from settings: 21

thank you in advanced for all your help..
xmodpt

You don't need template vars at all. Delete this.

You need to add this to your init.py file.

    def get_template_configs(self):
        return [
            dict(type="settings", custom_bindings=False, template="sla_timelapse_settings.jinja2")
        ]

this line 40 in the js file

needs to be

elements: ["#settings_plugin_slatimelapse"]

this line 4 is using the wrong plugin_identifier now because you changed it setup.py

needs to be

<input type="number" id="gpio_pin" min="0" max="40" step="1" data-bind="value: settings.plugins.slatimelapse.gpio_pin">

You're missing the AssetPlugin mixin declaration so the js file is loaded.

Basically there's so much wrong in this it would be faster for me to fix it and submit a PR (the way I did before)

What I question is why you didn't merge my previous PR as it was fully functional from the perspective of settings saving, and should have been taking snapshots. If you uninstall what you have now and in plugin manager copy/paste this url into the ...from URL field and click Install you should have a functional snapshot taker.

https://github.com/jneilliii/SLA-Timelapse/archive/refs/heads/main.zip

stand by, I just noticed my fork was also missing the AssetPlugin mixin. Let me fix that up real quick.

i am sorry but i did made so many changes and tests i got lost and as i said i an just strating on this,

How ever your sujestions did work and it works now. however i have noticed that when i press save in the template then i have to restart octoprint for the changes to be implemented.

next to all of it again but now for the delay value and for a new value ( that i had in my terminal version) that allows the user to ignore "x" amount of triggers ( corresponding to the VAT hight) before starting to take snapshots otherwise it will have "x" amount of snapshots of the vat before the print starts to come out of it.

thank you

PS- i did try to merge both codes and just modifying the original (yours) but i got lost so i decided to start where i knew it was working

Ok, now if you install this one in plugin manager ...from URL it should load and be able to save settings, etc.

https://github.com/jneilliii/SLA-Timelapse/archive/refs/heads/main.zip

i did change my one and it works

but i will try your version

Do you mean that after saving it doesn't monitor the newly updated pin? If that is the case, then it would be something that you could fix by adding this to init.py

    def on_settings_changed(self, data):
        old_gpio = self._settings.get_int(["gpio_pin"])
        octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
        if old_gpio != self._settings.get_int(["gpio_pin"]):
            self._setup_gpio()

just tested your version and found the debouncing needs work and that once you change the gpio in the settings also need to restarts octoprint for it to take efect... like mine

looks like I commented at the same time, see the comment before yours relative to having to restart.

hehehehehe talking about timming... gona give it a shot... TY

I pushed those changes to my fork just now.

the only caveat is that he previous pin may still being monitored when you change stuff. not sure if there is a way in RPi.GPIO to stop monitoring a pin, but that's something you can add in the on_settings_save inside the if condition.

BiG TY for all the help :smiley: :smiley: :smiley:

ok just added the code and it works... sort of...
if i change from 21 to 19 and save... it starts working on 19 just fine withou a reboot but if i change it back to 21... it saves 21 but doesn't work... it's stuck in 19... and aldo it shows 21 in the settings and in the log print that is setup to 21 ... it isn't ... it's still in 19

odd

but if i reboot the pi all works

odd, but it must work as OctoRelay does it... you can change gpio's on the fly and no need for reboot however i am no Inteligent guy and i am strugling in finding how they do it ... ho well ... it works regardless

Ah...I know why. Stand by.

I think it might be fixed now. Give it another try. Noticed my on_settings_save callback wasn't set properly and was named on_settings_changed. If that doesn't work, make sure your latest code is pushed to github and I can review it there.