Variable Folder Creation

Posted on
Tue Nov 20, 2018 9:43 am
CliveS offline
Posts: 770
Joined: Jan 10, 2016
Location: Medomsley, County Durham, UK

Variable Folder Creation

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.

CliveS

Indigo 2023.2.0 : macOS Ventura 13.6.3 : Mac Mini M2 : 8‑core CPU and 10‑core GPU : 8 GB : 256GB SSD
----------------------------------------------------------------------------------
The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer

Posted on
Tue Nov 20, 2018 10:05 am
FlyingDiver offline
User avatar
Posts: 7210
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Variable Folder Creation

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

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Nov 20, 2018 10:32 am
CliveS offline
Posts: 770
Joined: Jan 10, 2016
Location: Medomsley, County Durham, UK

Re: Variable Folder Creation

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!!!

CliveS

Indigo 2023.2.0 : macOS Ventura 13.6.3 : Mac Mini M2 : 8‑core CPU and 10‑core GPU : 8 GB : 256GB SSD
----------------------------------------------------------------------------------
The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest