PluginConfig.xml update fields

Posted on
Sun Dec 09, 2018 7:05 pm
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

PluginConfig.xml update fields

Hi,

Struck a couple of issues which have worked around - but wonder whether is better way..

1.Using PluginPrefs.
Am using PluginPrefs['access_token'] to store read-only code generated access token.
Created from PluginConfig page, after button press.
The issue I had was the ValuesDict['access_token'] was always blank - as was generated after opening. (and access_token is blank until button press)
On closing/saving the PluginConfig window it appears from my debugging that the blank access_token was written to PluginPrefs.
I presume this is expected?

I have worked around by updating the ValuesDict to the access_token within ValidatePrefsConfigUi.

Is this the best way to deal with PluginPrefs changing via code whilst Config Window is open?

2. Updated PluginConfig field

As a continuation of above - After button press access_token is generated/returned.
Can I update the already open PluginConfig window immediately with this new code? (without closing/reopening which does display it)
Seem to think I am missing something basic here for this one??

Meanwhile... I'll flick my way through examples....

Thanks

Glenn

Posted on
Wed Dec 12, 2018 1:02 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: PluginConfig.xml update fields

GlennNZ wrote:
Hi,

Struck a couple of issues which have worked around - but wonder whether is better way..

1.Using PluginPrefs.
Am using PluginPrefs['access_token'] to store read-only code generated access token.
Created from PluginConfig page, after button press.
The issue I had was the ValuesDict['access_token'] was always blank - as was generated after opening. (and access_token is blank until button press)
On closing/saving the PluginConfig window it appears from my debugging that the blank access_token was written to PluginPrefs.
I presume this is expected?

I have worked around by updating the ValuesDict to the access_token within ValidatePrefsConfigUi.

Is this the best way to deal with PluginPrefs changing via code whilst Config Window is open?


Yes. That is exactly how valuesDict is to be used. That's not a workaround.

GlennNZ wrote:
2. Updated PluginConfig field

As a continuation of above - After button press access_token is generated/returned.
Can I update the already open PluginConfig window immediately with this new code? (without closing/reopening which does display it)
Seem to think I am missing something basic here for this one??

Meanwhile... I'll flick my way through examples....

Thanks

Glenn


First question to ask yourself - why are you displaying the access_token at all? It's read only. The original Ecobee code did that, and I took it out.

Look at the code for the Ecobee 2 account device creation. It's doing the same thing. Or go back to the original Ecobee plugin and look at the code for plugin prefs there. The PIN number field is updated in real time after a button press.

Here's the code from the button press in the config dialog (not the close dialog button):

Code: Select all
    def request_pin(self, valuesDict, typeId, devId):
        self.temp_ecobeeAccount = EcobeeAccount(None, API_KEY, None)
        pin = self.temp_ecobeeAccount.request_pin()
        if pin:
            valuesDict["pin"] = pin
            valuesDict["authStatus"] = "PIN Request OK"
        else:
            valuesDict["authStatus"] = "PIN Request Failed"
        return valuesDict

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

Posted on
Wed Dec 12, 2018 1:23 am
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: PluginConfig.xml update fields

Thanks for the detailed reply.

Follow completely, some of the code is threaded given the time it takes - so may have issue returning with 'button press' valuesDict. But at least understand the correct path!

Cheers

Glenn

Posted on
Wed Dec 12, 2018 10:23 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: PluginConfig.xml update fields

GlennNZ wrote:
Can I update the already open PluginConfig window immediately with this new code? (without closing/reopening which does display it)
Seem to think I am missing something basic here for this one??


From the 7.0 API changes announcement (yes, we're WAAAAY behind getting this stuff integrated into the mainline docs):

Added support for valuesDict['refreshCallbackMethod'] attribute which allows plugins to specify a UI refreshing callback method that is called approximately every second for updates. The callback method has the same signature as UI button actions and can return both a modified valuesDict and errorsDict for dynamic UI updating.


And Matt goes into more detail in another post.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Dec 12, 2018 2:04 pm
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: PluginConfig.xml update fields

jay (support) wrote:
GlennNZ wrote:
Can I update the already open PluginConfig window immediately with this new code? (without closing/reopening which does display it)
Seem to think I am missing something basic here for this one??


From the 7.0 API changes announcement (yes, we're WAAAAY behind getting this stuff integrated into the mainline docs):

Added support for valuesDict['refreshCallbackMethod'] attribute which allows plugins to specify a UI refreshing callback method that is called approximately every second for updates. The callback method has the same signature as UI button actions and can return both a modified valuesDict and errorsDict for dynamic UI updating.


And Matt goes into more detail in another post.


Thanks for the reference

Jay - that’s even easier to implement!

Posted on
Wed Dec 12, 2018 3:01 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: PluginConfig.xml update fields

GlennNZ wrote:
Jay - that’s even easier to implement!


Yeah, it's nice when you have longish running things that need to be represented in config dialogs, like bonjour discovery. I haven't retrofitted any of our plugins that do that sort of discovery, but at some point we'll probably do it. The Z-Wave interface uses it though for inclusion.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Dec 12, 2018 10:30 pm
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: PluginConfig.xml update fields

jay (support) wrote:
GlennNZ wrote:
Jay - that’s even easier to implement!


Yeah, it's nice when you have longish running things that need to be represented in config dialogs, like bonjour discovery. I haven't retrofitted any of our plugins that do that sort of discovery, but at some point we'll probably do it. The Z-Wave interface uses it though for inclusion.


Thanks Jay
Last stupid question follows
How do I programmatically change something like a ?Label - I can change Textfields easily enough - but they look relatively ugly/readonly/grey-out and not the best placement.
I see the Zwave box programmatically changes text/red etc... so must be possible...
Image


Although perhaps you have answered this here:

viewtopic.php?f=84&t=21029&p=163707&hilit=label#p163707


Cheers

Glenn

Posted on
Thu Dec 13, 2018 4:51 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: PluginConfig.xml update fields

GlennNZ wrote:
Although perhaps you have answered this here:

viewtopic.php?f=84&t=21029&p=163707&hilit=label#p163707

As far as I know, that's still the condition of things.

Code: Select all
<Field id="label_wanted" type="checkbox" defaultValue="false" hidden="true"/>

<Field id="label_to_show" type="label" hidden="true" enabledBindingId="label_wanted">
    <Label>Label:</Label>
</Field>


You'll need some kind of callback or other trigger to refresh the dialog.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu Dec 13, 2018 7:57 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: PluginConfig.xml update fields

GlennNZ wrote:
How do I programmatically change something like a ?Label - I can change Textfields easily enough - but they look relatively ugly/readonly/grey-out and not the best placement.
I see the Zwave box programmatically changes text/red etc... so must be possible...

Image

Davie is correct. It is just the visibility of that item that is dynamic, not the actual contents of the text. That is, inside the XML there are a bunch of ConfigUI Fields with a lot of different error/status messages and each one has a unique visibleBindingId value that points to a hidden checkbox field (with each error/status caption having its own hidden checkbox used soley to be able to toggle its visibility). It is a pain, and something we hope to improve.

Image

Posted on
Fri Dec 14, 2018 12:39 am
GlennNZ offline
User avatar
Posts: 1555
Joined: Dec 07, 2014
Location: Central Coast, Australia

PluginConfig.xml update fields

matt (support) wrote:
Davie is correct. It is just the visibility of that item that is dynamic, not the actual contents of the text. That is, inside the XML there are a bunch of ConfigUI Fields with a lot of different error/status messages and each one has a unique visibleBindingId value that points to a hidden checkbox field (with each error/status caption having its own hidden checkbox used soley to be able to toggle its visibility). It is a pain, and something we hope to improve.


I ignore commenting on the 'Davie' name....

But thanks for pointers and have found works fine if using visibleBinding for separate invisible configInfo field.

Within refreshmethod setting configInfo to whatever is needed.

Code: Select all
          <Field id="configInfo" justify='left' type="textfield" hidden='true' >
          </Field>
            <Field id="InfogenerateApp" alignwithControl='true' justify='left' type="label" fontColor="red" visibleBindingId="configInfo" visibleBindingValue="generate">
            <Label>        Generating a Wit.Ai Application....  </Label>
            </Field>
              <Field id="errGenerate" justify='left' type="label" fontColor="red" visibleBindingId="configInfo" visibleBindingValue="errGenerateExists">
            <Label>         Error Generating a Wit.Ai Application. It already Exists. Delete First.</Label>
            </Field>
                  <Field id="generateSucess" justify='left' type="label" fontColor="red" visibleBindingId="configInfo" visibleBindingValue="createsuccess">
            <Label>         Successfully Generated a Wit.Ai Application....</Label>
            </Field>
              <Field id="updating" justify='left' type="label" fontColor="red" visibleBindingId="configInfo" visibleBindingValue="update">
            <Label>         Updating Wit.Ai App this might take some time and you can close dialog.</Label>
            </Field>
              <Field id="updateComplete" justify='left' type="label" fontColor="red" visibleBindingId="configInfo" visibleBindingValue="upComplete">
            <Label>         Updating Wit.Ai App Completed Successfully.</Label>
            </Field>
                   <Field id="deleting" justify='left' type="label" fontColor="red" visibleBindingId="configInfo" visibleBindingValue="delete">
            <Label>         Deleting Wit.Ai App ....</Label>
            </Field>
            <Field id="delComplete" justify='left' type="label" fontColor="red" visibleBindingId="configInfo" visibleBindingValue="delsuccess">
            <Label>         Successfully deleted Wit.Ai App ....</Label>
            </Field>
                 <Field id="deleteerror" justify='left' type="label" fontColor="red" visibleBindingId="configInfo" visibleBindingValue="delexists">
            <Label>         Error Deleting Wit.Ai App. It doesn't seem to Exist....</Label>
            </Field>
                     <Field id="deleteerror2" justify='left' type="label" fontColor="red" visibleBindingId="configInfo" visibleBindingValue="delerr">
            <Label>         Error Deleting Wit.Ai App.  Perhaps try again?.</Label>
            </Field>

          <Field id="refreshCallbackMethod" type='textfield' hidden='true' defaultValue="UIrefreshMethod">
          </Field>
Last edited by GlennNZ on Fri Dec 14, 2018 5:23 am, edited 1 time in total.

Posted on
Fri Dec 14, 2018 4:50 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: PluginConfig.xml update fields

Davie is my mafia name. Well, it's technically "Davie Two Donut".

Matt, we need to talk...

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri Dec 14, 2018 9:59 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: PluginConfig.xml update fields

Sorry Davie, didn't mean to dox ya.

Image

Posted on
Fri Dec 14, 2018 4:45 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: PluginConfig.xml update fields

matt (support) wrote:
Sorry Davie, didn't mean to dox ya.

You can't unscramble an egg, Matt. :D

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests