How to add/remove Device.xml configui field filter?

Posted on
Fri Nov 15, 2013 3:41 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

How to add/remove Device.xml configui field filter?

Is it possible to dynamically modify a Plugin's Devices.xml configUI field filter setting. For example, in the xml:
Code: Select all
         <Field id="heatingId" type="menu">
            <Label>Heat Source Controller:</Label>
            <List class="indigo.devices" filter="indigo.thermostat"/>
         </Field>

I would like to be able to add or remove the filter. The easy option is to leave it out altogether but being able to select whether the filter is active or not would be better.

Thanks for any help :)

Posted on
Fri Nov 15, 2013 10:46 am
berkinet offline
User avatar
Posts: 3297
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: How to add/remove Device.xml configui field filter?

If you just want to change the list when the configUI loads, you can use:
    <List class="self" method="getMyList"/>

Or, if you want to re-write the list during the config session, use:
    <List class="self" method="getMyList" dynamicReload="yes"/>

Where "getMyList" is a method defined in your plugin.py.

Here is an example method:
Code: Select all
def getMyList(self, filter="", valuesDict=None, typeId="", targetId=0):
        myArray = []
        for device in sorted(indigo.devices):
            if device.deviceTypeId == 'foo':
                myArray.append((device.id, device.name))

        return myArray


For a complete explanation see this page in the docs.

Posted on
Fri Nov 15, 2013 12:11 pm
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: How to add/remove Device.xml configui field filter?

Thank you for giving such a complete and helpful answer to my question :)

I have now implemented it in my Plugin and it does exactly what I want.

Thanks again :D

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest