[ANSWERED]: update Address/description fields in devices

Posted on
Wed Jul 30, 2014 11:21 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

[ANSWERED]: update Address/description fields in devices

Creation of the devices works fine.
Code: Select all
                  indigo.device.create(
                     protocol=indigo.kProtocol.Plugin,
                     address=theMAC,
                     name="MAC-"+theMAC,
                     description="",
                     pluginId="com.karlwachs.fingscan",
                     deviceTypeId="IP-Device",
                     folder=self.deviceFolderID
                     )

can I LATER update the address or description fields?
tried
Code: Select all
               localPropsCopy = dev.pluginProps
               localPropsCopy.update({"description":"newTEXT"})
               dev.replacePluginPropsOnServer(localPropsCopy)

and update State.. does not work.

any advice?

Karl

Posted on
Wed Jul 30, 2014 1:09 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: update Address/notes/description fields in devices

Hey Karl - check out the WUnderground plugin. I update the address field in that.

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

[My Plugins] - [My Forums]

Posted on
Wed Jul 30, 2014 1:51 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: update Address/notes/description fields in devices

thanks

both statements work for the ADDRESS field but not for the DESCRIPTION field! ==> Matt , Jay is this correct?


Code: Select all
               props = dev.pluginProps

               props["address"]="new text"   ### works
               props.update({"address":"new text"})   ### works
               props["description"]="new text"  ### does not work
               props.update({"description":"new text"})   ### does not  work

               dev.replacePluginPropsOnServer(props)


KArlk

Posted on
Wed Jul 30, 2014 2:46 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: update Address/notes/description fields in devices

This is a bit more confusing than I would like, but for description do:

Code: Select all
dev.description = "new desc here"
dev.replaceOnServer()

Make sure dev is up-to-date (recently retrieved via indigo.devices[]) as the replace call above replaces the entire device with the local instance (python instance dev in this case).

Image

Posted on
Wed Jul 30, 2014 4:14 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: [ANSWERED]: update Address/description fields in devices

ok thx

Posted on
Tue Jan 09, 2018 8:26 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: [ANSWERED]: update Address/description fields in devices

A follow on to this question, if I may?

If I use New... to create a new device which then opens Edit Device Settings... where I want to input an IP address in the IP Address field (in this example). I want to save this IP Address as the devices address. How do I do this in the method closedDeviceConfigUi ?

Updating the plugin props doesn't seem to work, possibly because the props are then getting nuked on the return from the method? I have tried adding address to the valuesDict but this just adds an unwanted entry into globalProps. :?

Posted on
Tue Jan 09, 2018 10:00 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: [ANSWERED]: update Address/description fields in devices

here is how I do it:
0. in init:
self.updateRequired = ""
1. in validate device ui ..
Code: Select all
valuesDict["updateDescription"] = "new info you wan to put into the notes field eg IP number"
self.updateRequired = dev.id
2. the in main loop check
Code: Select all
if self.updateRequired  !="":
  dev= indigo.devices[self.updateRequired]
  dev.description =  dev.pluginProps["updateDescription"]
  dev.replaceOnServer()
  self.updateRequired = ""

thats works, have not found a more elegant solution yet, if anyone has one, let me know

Karl

ps doing
Code: Select all
  dev.description =  "new info"
  dev.replaceOnServer()
in valdate device ui will be overwritten when indigo does the device save

Posted on
Tue Jan 09, 2018 12:38 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: [ANSWERED]: update Address/description fields in devices

autolog wrote:
If I use New... to create a new device which then opens Edit Device Settings... where I want to input an IP address in the IP Address field (in this example). I want to save this IP Address as the devices address. How do I do this in the method closedDeviceConfigUi ?

Updating the plugin props doesn't seem to work, possibly because the props are then getting nuked on the return from the method? I have tried adding address to the valuesDict but this just adds an unwanted entry into globalProps. :?


Do you have "address" in your device's props? It should get mirrored to the dev.address property. In Indigo 7, I believe we started allowing arbitrary properties to get set in the validateDeviceConfigUi so I believe you can just add it there. If that doesn't work, you can always add a hidden field to your device's ConfigUI XML with the name "address" and populate that in validateDeviceConfigUi.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jan 09, 2018 1:12 pm
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: [ANSWERED]: update Address/description fields in devices

jay (support) wrote:
autolog wrote:
If I use New... to create a new device which then opens Edit Device Settings... where I want to input an IP address in the IP Address field (in this example). I want to save this IP Address as the devices address. How do I do this in the method closedDeviceConfigUi ?

Updating the plugin props doesn't seem to work, possibly because the props are then getting nuked on the return from the method? I have tried adding address to the valuesDict but this just adds an unwanted entry into globalProps. :?


Do you have "address" in your device's props? It should get mirrored to the dev.address property. In Indigo 7, I believe we started allowing arbitrary properties to get set in the validateDeviceConfigUi so I believe you can just add it there. If that doesn't work, you can always add a hidden field to your device's ConfigUI XML with the name "address" and populate that in validateDeviceConfigUi.


Thanks Jay :D

Setting a field with an id of address in the ConfigUI worked. The User sees a field label of IP Address and then when it is saved the device address is set.

Easy when you know how. :wink: Thanks again. :)

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest