Page 1 of 1

Function when UI form is loading?

PostPosted: Tue Jun 26, 2018 2:10 pm
by Colorado4Wheeler
I seem to remember reading on the forums a method/function that would fire when a form was loading before the user actually saw it that would allow the plugin to fill in some fields, am I on crack? I need to populate custom menu fields that just show up as blank because it's not a pre-defined static list (defaultValue doesn't work on my custom fields).

Re: Function when UI form is loading?

PostPosted: Tue Jun 26, 2018 2:23 pm
by autolog

Re: Function when UI form is loading?

PostPosted: Tue Jun 26, 2018 2:28 pm
by Colorado4Wheeler
Yea, that's what I was trying to remember was that thread, but that's only for a menu item and not for a device.

Re: Function when UI form is loading?

PostPosted: Tue Jun 26, 2018 2:33 pm
by DaveL17
Are you talking about getDeviceConfigUiValues()?


Sent from my iPhone using Tapatalk

Re: Function when UI form is loading?

PostPosted: Tue Jun 26, 2018 3:20 pm
by Colorado4Wheeler
DaveL17 wrote:
Are you talking about getDeviceConfigUiValues()?


Sent from my iPhone using Tapatalk

Maybe, I'm not sure. I can't find that one in the API docs.

Re: Function when UI form is loading?

PostPosted: Tue Jun 26, 2018 3:40 pm
by DaveL17
I don't think it's in the docs.

Code: Select all
getDeviceConfigUiValues(self, valuesDict, typeId, devId)


Multitool Plugin Method Signature Tool:
Code: Select all
   Multitool                       self.getDeviceConfigUiValues: ArgSpec(args=['self', 'pluginProps', 'typeId', 'devId'], varargs=None, keywords=None, defaults=None)
   Multitool                       Docstring: None

Re: Function when UI form is loading?

PostPosted: Tue Jun 26, 2018 3:41 pm
by autolog
Colorado4Wheeler wrote:
DaveL17 wrote:
Are you talking about getDeviceConfigUiValues()?


Sent from my iPhone using Tapatalk

Maybe, I'm not sure. I can't find that one in the API docs.

That's the one. You mentioned Menus which is why I gave you the link I did. :)

Take a look at the Plugin Developer Documenter Plugin - an excellent piece of documentation from @RogueProeliator. :)

Re: Function when UI form is loading?

PostPosted: Tue Jun 26, 2018 4:25 pm
by Colorado4Wheeler
DaveL17 wrote:
I don't think it's in the docs.

Oh, well that is an excellent way to use the API, word of mouth... :roll: :roll: :shock: :shock: :lol: :lol:

Thanks for the unveiling of the super secret method!

autolog wrote:
That's the one. You mentioned Menus which is why I gave you the link I did.

I see that, I think my mind was focused on wanting to get a device config version of the menu function I had seen somewhere on the forums.

autolog wrote:
Take a look at the Plugin Developer Documenter Plugin - an excellent piece of documentation from @RogueProeliator.

That looks interesting, I'l. check it out.

Re: Function when UI form is loading?

PostPosted: Tue Jun 26, 2018 5:16 pm
by Colorado4Wheeler
Love this command. I've worked around not having this for years and a good number of my plugins had to do some pretty crazy stuff to get "pre-calculations" done, like hiding the entire form until they checked a box that then had a callback that then did the calculation that then enabled the fields.

In standard Indigo API fashion I see this is across all config UI's with a simple name change - also making my Actions much easier to default now too!

Thank you for the enlightenment!

Re: Function when UI form is loading?

PostPosted: Tue Jun 26, 2018 8:40 pm
by DaveL17
For the future, here's an example:

Code: Select all
    def getDeviceConfigUiValues(self, valuesDict, typeId, devId):

        if typeId == 'someTypeId' and 'devicePropertyName' not in valuesDict.keys():
            valuesDict['devicePropertyName'] = "defaultValue"

        return valuesDict


Re: Function when UI form is loading?

PostPosted: Tue Jun 26, 2018 8:53 pm
by Colorado4Wheeler
Yup, I figured that out as it was the reason I needed the method.

Re: Function when UI form is loading?

PostPosted: Tue Jun 26, 2018 9:01 pm
by DaveL17
That wasn't for you, my brother--that was for the next guy. :D