Another issue validateDeviceConfigUi()

Posted on
Wed Sep 04, 2019 8:37 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Another issue validateDeviceConfigUi()

This is baffling me. validateDeviceConfigUi() receives valuesDict for a new device, changes the value of one entry, and returns valuesDict. If I log valuesDict just before returning it, I can see the entry in question has been changed. But, when the device is created, the property has the original, blank, value. Then, if I just open the device, click edit, then save, the device property is correctly saved.

???

Posted on
Wed Sep 04, 2019 9:04 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Another issue validateDeviceConfigUi()

Can you copy/paste your validateDeviceConfigUi() method so I can see specifically what it is doing (and returning)?

Image

Posted on
Wed Sep 04, 2019 9:08 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Another issue validateDeviceConfigUi()

matt (support) wrote:
Can you copy/paste your validateDeviceConfigUi() method so I can see specifically what it is doing (and returning)?
Code: Select all
def validateDeviceConfigUi(self, valuesDict, typeId, devId):
      func = inspect.stack()[0][3]
      self.logger.debug(u"%s: called with typeId=%s, devId=%s, and valuesDict=%s.", func, typeId, devId, valuesDict)
      errorsDict = indigo.Dict()

      if not valuesDict['outletNum'] or valuesDict['outletNum'] == None or valuesDict['outletNum'] == "":
         valuesDict['outletNum']   = "00"

      if not valuesDict['childId'] or valuesDict['childId'] == None or valuesDict['childId'] == "":
         valuesDict['childId']   = str(valuesDict['deviceId']) + valuesDict['outletNum']
      
      # If we have been asked to re-initialize this device...
      if ('initialize' in valuesDict and valuesDict['initialize']):
         self.initializeDev(valuesDict)
      valuesDict['newDev'] = False
      valuesDict['initialize'] = False

      return (True, valuesDict, errorsDict)
Note initialize is not being called

Posted on
Wed Sep 04, 2019 9:17 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Another issue validateDeviceConfigUi()

I just tried it in a testing plugin and am not seeing what you are (in mine the property updated).
berkinet wrote:
But, when the device is created, the property has the original, blank, value

How specifically are you inspecting the value when you see the wrong/blank value?

Image

Posted on
Wed Sep 04, 2019 9:19 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Another issue validateDeviceConfigUi()

matt (support) wrote:
...How specifically are you inspecting the value when you see the wrong/blank value?

>>> print indigo.devices[1555438002] # "new device"

And, it throws an error in deviceStartComm

Posted on
Wed Sep 04, 2019 9:51 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Another issue validateDeviceConfigUi()

What do you mean it throws an error in startComm? That might actually be what is causing it to fail to update...

Image

Posted on
Wed Sep 04, 2019 9:53 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Another issue validateDeviceConfigUi()

matt (support) wrote:
What do you mean it throws an error in startComm? That might actually be what is causing it to fail to update...
It throws the error because it tries to add 1 to the value of dev.pluginProps{'outletNum']

Posted on
Wed Sep 04, 2019 10:01 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Another issue validateDeviceConfigUi()

I think you have something else going on here. I stripped it down to this:

Code: Select all
   def validateDeviceConfigUi(self, valuesDict, typeId, devId):
      valuesDict["pollRate"] = 123
      return (True, valuesDict)

   def deviceStartComm(self, dev):
      indigo.server.log("pollRate: {}".format(dev.pluginProps.get("pollRate", "not defined")))

and it works as expected.

Image

Posted on
Wed Sep 04, 2019 10:09 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Another issue validateDeviceConfigUi()

matt (support) wrote:
I think you have something else going on here...

I am pretty sure you are right. But I sure as heck can't figure out what. I'll pound on it for a while. Thainks

Posted on
Wed Sep 04, 2019 10:10 am
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Another issue validateDeviceConfigUi()

It throws the error because it tries to add 1 to the value of dev.pluginProps{'outletNum']

Maybe irrelevant if you are handling it, but I might point out you are setting the initial value of outletNum to a string not an integer...

Posted on
Wed Sep 04, 2019 10:11 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Another issue validateDeviceConfigUi()

RogueProeliator wrote:
It throws the error because it tries to add 1 to the value of dev.pluginProps{'outletNum']

Maybe irrelevant if you are handling it, but I might point out you are setting the initial value of outletNum to a string not an integer...

Well, I was summarizing... it actually does foo = int(bar) :wink:

Posted on
Wed Sep 04, 2019 10:13 am
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Another issue validateDeviceConfigUi()

berkinet wrote:
Well, I was summarizing... it actually does foo = int(bar) :wink:


If you posted the actual code (for both methods) someone else might be able to spot the error.

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

Posted on
Wed Sep 04, 2019 10:16 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Another issue validateDeviceConfigUi()

FlyingDiver wrote:
berkinet wrote:
Well, I was summarizing... it actually does foo = int(bar) :wink:


If you posted the actual code (for both methods) someone else might be able to spot the error.


The problem is 100% clear the property has no value after finishing creation. That missing value causes the error I mentioned. If I re-edit the same exact device, there property gets set. I can post before and after device settings.

Posted on
Wed Sep 04, 2019 10:46 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Another issue validateDeviceConfigUi()

I think I may have found the cause... The field I was having problems setting was not visible at the time the new value was returned to the ConfigUI. So, my guess is, either it was not updated because it was not visible, or it was not waved when the ConfigUI was closed. As soon as I made the field visible, the problem went away.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest