Page 1 of 1

Variable Folder Creation

PostPosted: Tue Nov 20, 2018 9:43 am
by CliveS
I am trying to add a Variable Folder to a plugin.
I can create and update the variable and put it in a predefined Folder but can see no documentation on creating a new Folder.

Re: Variable Folder Creation

PostPosted: Tue Nov 20, 2018 10:05 am
by FlyingDiver
Here's an excerpt from the device creation code in the Lutron plugin:

Code: Select all
        elif self.group_by == "Room":
            folderName = u"Lutron {}".format(room)
            if folderName in indigo.devices.folders:
                theFolder = indigo.devices.folders[folderName].id
            else:
                self.logger.debug("Creating Device Folder: '{}'".format(folderName))           
                theFolder = indigo.devices.folder.create(folderName).id


For a Variable folder, it's almost the same. From my HTTPd plugin:

Code: Select all
        if "HTTPd" in indigo.variables.folders:
            myFolder = indigo.variables.folders["HTTPd"]
        else:
            myFolder = indigo.variables.folder.create("HTTPd")
        self.pluginPrefs["folderId"] = myFolder.id

Re: Variable Folder Creation

PostPosted: Tue Nov 20, 2018 10:32 am
by CliveS
Joe, thanks for that, works a treat.
I was trying every 'variable' of indigo.variable.create I could think of but never thought it would need variables instead of variable.
I had pulled a load of plugins apart to try and find that.....thanks!!!