Programmatically creating and renaming

Posted on
Thu Aug 15, 2019 11:55 am
joshh385 offline
Posts: 24
Joined: Jan 04, 2019

Programmatically creating and renaming

My plugin automatically creates indigo devices based on responses from a third party api on setup. That all seems to be working well. The third party api will send an update message over a web socket connection if a device is changed on their side (they have an iPhone app for their service, and you can make various modifications to the devices in that app such as renaming).
I am handling that incoming message, pulling out the new value and then updating the pluginProps for the appropriate device. Things appear to work - no errors logged, and inspecting the pluginProps value shows the new name. But, the name isn't updated in the Indigo UI. This is a snippet of what I'm doing to update the name

dev = indigo.devices[indigodevid]
newProps = dev.pluginProps
newProps["name"] = updatemsg["general"]["v2"]["name"]
dev.replacePluginPropsOnServer(newProps)

I wondered if it might be related to the issue discussed at viewtopic.php?f=108&t=22138&p=174555&hilit=rename#p174555 but it doesn't sound quite the same.

Posted on
Thu Aug 15, 2019 12:42 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Programmatically creating and renaming

Looks like exactly the same problem. If you quit the client and relaunch it, does the device have the right name?

On the other hand, are you sure that automatically renaming devices is a good idea? As a user, it would seriously annoy me.

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

Posted on
Thu Aug 15, 2019 1:11 pm
joshh385 offline
Posts: 24
Joined: Jan 04, 2019

Re: Programmatically creating and renaming

No such luck - closed and relaunched and the name is the same.
That's definitely a fair point. Haven't quite decided what I want to do there. I'm working with the name property right now just because I thought it would be a quick and easy one to verify (it's simple to change in the iPhone app, and easy to see the change in Indigo). I might end up making it a config option to have the device names auto update, or maybe use a different property/put something in the notes.

Posted on
Thu Aug 15, 2019 1:22 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Programmatically creating and renaming

'name' isn't in pluginProps. You need to do something like:

Code: Select all
dev = indigo.devices[indigodevid]
dev.name = updatemsg["general"]["v2"]["name"]
dev.replaceOnServer()


https://wiki.indigodomo.com/doku.php?id ... vice_class

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

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 10 guests