Need help with plugin creation for a timelapse

crap missed all the other tweaks....

hello mate ... here i am again....

made all changes you have given me and yes i do get the on/off button on the nav but it does nothing.
meanwhile i have made alot of changes since my last commit and i have tested them and they work,

i ask of you 3 things

  • how can i get the on/off toogle working (default OFF)
  • how can i add an image to the settings (kinda of a png with some instructions) and where to save the png
  • how to display the avaliable (auto-generated) timelapses avi files and allow the user to download and or delete them

i know it's allot to ask
GIT updated -> https://github.com/xmodpt/test/tree/main
thank you

I think this will do it. Update slatimelapse.js by jneilliii · Pull Request #3 · xmodpt/test · GitHub

create an img folder inside static sub-folder and save your png there. then in your settings jinja2 file reference it as href="/plugin/<plugin_identifier>/static/img/<filename>"

this will require a bit of work. you'll need to create a simpleApiPlugin mixin to generate the file list on the python side, and then handle retrieving that data and displaying on the tab. the js file would need an observableArray defined and then you fill that with the list results from an api call in on_tab_change callback.

it doesn't work for some reason as i had it before and comented out to place your sujestion,

This is going to be a nightmare and a mess.... any exemples i can follow ?

thank you 1milion times

works perfectly fine for me. I just installed using this URL in plugin manager > get more > ...from URL.

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

The one thing I do see in your code is that nowhere in your python file are you checking to see if the enabled settings is on or not. Somewhere you need the logic to not do anything when that is not enabled. if self._settings.get_boolean(["enabled"]): for example. My changes only got it to where it was saving the setting.

Think I figured it out. You're missing

    def get_assets(self):
        return dict(
            js=["js/slatimelapse.js"]
        )

In your python file and had some js formatting issues. I've fixed all this up in my patch-2 pull request. You should be able to just go here and click the merge button.

yes i got there to in the end... lol

how ever , aldo the toggle works it doesn't do anything as with it on or off the plugin is still working in the background.

what do you think of the changes?

crap just read your post.... whell let's see if i can figure it out

git updated

In on_settings_save stop the run with the remove_event_detect callback we discussed earlier, which also seems to be missing in your latest code for gpio change in the if condition. If I'm going to spend so much time commenting on your code, you could at least take the time to incorporate the changes or ask questions related to what they do. At this point I've worked more on your plugin than my own for the past week.

sorry about that and thank you

hello mate

i am really sorry about all the issues i may caused you and i thing i am moving 5 steps forword and 10 steps back
in the new version, i am able so change the settings and save them and it works.
and the on off toggle also works and it enebles and disables the plugin

however i must of done something wrong as when i press the disable toogle, all other plugins are also disabled ( octorelay) stop working

can you take a look at it ? please

thank you

I don't do much with GPIO stuff, but I suspect it's because you're using GPIO.cleanup(), instead of using GPIO.remove_event_detect(pin). Something like this might work to prevent cleaning up the entire GPIO stuff. You may have to play around with the if logic some.

    def on_settings_save(self, data):
        old_enabled = self.enabled
        old_pin = self._settings.get_int(["gpio_pin"])
        # Call parent method to handle settings save
        SettingsPlugin.on_settings_save(self, data)
        # Check if enabled state has changed
        new_enabled = self._settings.get_boolean(["enabled"])
        new_pin = self._settings.get_int(["gpio_pin"])
        if old_enabled != new_enabled:
            self.enabled = new_enabled

        if old_pin != new_pin or old_enabled and not new_enabled:
            GPIO.remove_event_detect(old_gpio)  # Remove event detection for old pin
         
        if new_enabled and old_pin != new_pin:
            self._setup_gpio()  # Set up GPIO for the new pin