How to use 'refreshCallbackMethod' in Devices.xml

Posted on
Sun Jul 05, 2020 9:55 am
hannt offline
User avatar
Posts: 81
Joined: Jul 08, 2011
Location: TN USA

How to use 'refreshCallbackMethod' in Devices.xml

Trying to implement 'refreshCallbackMethod' for a custom device plugin. I read the post how to use : valuesDict['refreshCallbackMethod'] documenting how to use it, but it isn't working for me. I've implemented the callback method similar to the sample provided, which also writes a log entry so I know when it is called. However, I'm having trouble defining it in the config UI XML. I though it would look something like this:

Code: Select all
<ConfigUI refreshCallbackMethod='refreshDeviceConfigUi'>
    ...
</ConfigUI>
I also tried:

Code: Select all
<ConfigUI>
    <refreshCallbackMethod>refreshDeviceConfigUi</refreshCallbackMethod>
    ...
</ConfigUI>
What is the correct way to define this in Devices.xml?

Posted on
Tue Jul 07, 2020 5:25 pm
matt (support) offline
Site Admin
User avatar
Posts: 20075
Joined: Jan 27, 2003
Location: Texas

Re: How to use 'refreshCallbackMethod' in Devices.xml

It wasn't very clear on that other forum thread so here is an example. Although it might be possible to do via XML, it is easier to just handle by overriding one of these methods (use the first one unless you are using the device factory UI option): And note you can conditionalize it based on the passed in device typeId if you need.

Code: Select all
   def getDeviceConfigUiValues(self, pluginProps, typeId, devId):
      valuesDict = pluginProps
      errorMsgDict = indigo.Dict()
      valuesDict['refreshCallbackMethod'] = 'nameOfYourRfreshMethod'
      return (valuesDict, errorMsgDict)

   def getDeviceFactoryUiValues(self, devIdList):
      valuesDict = indigo.Dict()
      valuesDict['refreshCallbackMethod'] = 'nameOfYourRfreshMethod'
      errorMsgDict = indigo.Dict()
      return (valuesDict, errorMsgDict)

Image

Posted on
Wed Jul 08, 2020 6:50 pm
hannt offline
User avatar
Posts: 81
Joined: Jul 08, 2011
Location: TN USA

Re: How to use 'refreshCallbackMethod' in Devices.xml

matt (support) wrote:
It wasn't very clear on that other forum thread so here is an example. Although it might be possible to do via XML, it is easier to just handle by overriding one of these methods (use the first one unless you are using the device factory UI option): And note you can conditionalize it based on the passed in device typeId if you need.


Thanks, Matt! This is very useful information - I didn't know about 'getDeviceConfigUiValues'. For what I'm doing, that should work even without 'refreshCallbackMethod'.

Posted on
Thu Jul 09, 2020 6:57 am
hannt offline
User avatar
Posts: 81
Joined: Jul 08, 2011
Location: TN USA

Re: How to use 'refreshCallbackMethod' in Devices.xml

As a followup, I was able to get t refreshCallbackMethod working in Devices.xml without using getDeviceConfigUiValues. Not sure if 'textfield' is the correct type to define this, but it seems to work.

Code: Select all
<ConfigUI>
    <Field id="refreshCallbackMethod" type="textfield" hidden="true" defaultValue="refreshDeviceConfigUi"/>
    ....
</ConfigUI>

Posted on
Thu Jul 09, 2020 3:09 pm
matt (support) offline
Site Admin
User avatar
Posts: 20075
Joined: Jan 27, 2003
Location: Texas

Re: How to use 'refreshCallbackMethod' in Devices.xml

Yep, that (using textfield) look correct for the XML definition.

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests