setting dev.description in validateDeviceConfigUi()

Posted on
Tue May 17, 2016 8:19 am
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

setting dev.description in validateDeviceConfigUi()

I am trying to set the Notes field when the devices edit exits (save).

when i set dev.description in the method it gets ignored, as -I believe- the valuesDict overwrites the props.

I also tried to set valuesDict["description"] but that does not do anything either.

Currently I am saving the text into a variable and in the loop, when the variable is set I am setting dev.desrciption to the contents of the variable.

I know there must be an easier way..

Karl

Posted on
Wed May 18, 2016 8:34 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: setting dev.description in validateDeviceConfigUi()

Matt, Jay any feedback?

Posted on
Wed May 18, 2016 9:07 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: setting dev.description in validateDeviceConfigUi()

There isn't currently logic to have valuesDict["description"] push into the editable description field.

You can change it by updating the property on the device instance then calling replaceOnServer:

dev.description = "new description here"
dev.replaceOnServer()

However, I'm not sure how well that will work inside the validate method. I think that it might overwrite that change when the dialog is closed, but you should try it to see.

Image

Posted on
Wed May 18, 2016 9:34 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: setting dev.description in validateDeviceConfigUi()

tried that, it is overwritten by valuesDict

Saving the info to a variable/ props in def validateDeviceConfigUi ():
valuesDict["description"] = "new description"

and then in the runConcurrentThread:

Code: Select all
def runConcurrentThread(self):
   for dev in indigo.devices.iter(thisPluginId):
    props=dev.pluginProps
    if props["description'"] !="":
      dev.description = "new description here"
      props{'description']=""
    dev.replaceOnServer()


does the trick.

Karl
Last edited by kw123 on Thu May 19, 2016 8:04 am, edited 2 times in total.

Posted on
Thu May 19, 2016 6:44 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: setting dev.description in validateDeviceConfigUi()

Looks good. Do you later on in the runConcurrentThread() call replacePluginPropsOnServer() to push your modified props back to the Indigo Server?

Image

Posted on
Thu May 19, 2016 8:10 am
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: setting dev.description in validateDeviceConfigUi()

Matt, yes here the actual code I am using


Code: Select all

def runConcurrentThread(self):
 ....
   thisPluginId = "com.karlwachs..abc.xyz"
   for dev in indigo.devices.iter(thisPluginId):
        updateProps = False
        props = dev.pluginProps
        if "description" in props:
            if dev.description != props["description"] and props["description"] !="":
                dev.description = props["description"]
                props["description"] =""
                dev.replaceOnServer()
                updateProps = True
        if updateProps:
                dev.replacePluginPropsOnServer(props)
   ....


don't know if the second dev.replacePluginPropsOnServer after dev.replaceOnServer is needed.

Karl

actually don't understand the difference between dev.replacePluginPropsOnServer and dev.replaceOnServer
I guess the first one is ONLY for props.. do I need dev.replaceOnServer for dev.description.. i.e. is that not a prop?

==> is "dev.replacePluginPropsOnServer" included in "dev.replaceOnServer"????
Last edited by kw123 on Thu May 19, 2016 8:13 am, edited 1 time in total.

Posted on
Thu May 19, 2016 8:13 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: setting dev.description in validateDeviceConfigUi()

I think you need both but I'm not 100% sure w/o checking the code. You are correct that one replaces just the pluginProps, whereas the other replaces the entire instance. Use the former for a pluginProps change, the latter for everything else (including .description updating).

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 7 guests