changing Device UI columns

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

changing Device UI columns

I'd swear I've seen this discussed before, probably by me. But, no amount of searching has turned up anything.

When displaying Devices in the Indigo Home Window, is it possible for a plugin to alter the contents of any of the columns other than State?
For example, TP-Link makes several models of plugs, which can be queried from the device. It would be nice to show that info in the Model column instead of the Plugin Model type (as stored in dev.model). HS300(US) would be more meaningful than TP-Link Smart plug (all versions).

Similarly, since there are (at least) two different protocols for talking to the smart plugs, it would be nice to be able to display TP-Link Device MultiPlug instead of just TP-Link Device in the Protocol column.

And, finally, in the Address column. Since multi-plug devices have more than one outlet (up to six) I would like to make that visible by changing the Address from the simple dev.address entry, like 192.168.1.1 to something like 102.168.1.1:6.

Is any of this possible? If so, how?

TIA

Posted on
Wed Sep 04, 2019 5:43 am
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: changing Device UI columns

It is possible, yes. But IIRC, not *all* the fields are exposed. I do this in several of my plugins, thusly:

Code: Select all
            new_props = dev.pluginProps
            new_props['address'] = u"SOME VALUE"
            dev.replacePluginPropsOnServer(new_props)

I'm pretty certain that the Version field is likewise exposed. I can't recall off the top of my head if the Model field is.

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

[My Plugins] - [My Forums]

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

Re: changing Device UI columns

DaveL17 wrote:
...
Code: Select all
            new_props = dev.pluginProps
            new_props['address'] = u"SOME VALUE"
            dev.replacePluginPropsOnServer(new_props)
....

Thanks. Yes, there seems to be some magic mapping between pluginProps and other elements in the plugin? Like dev.pluginProps['address'] -> dev.address.

However, in the specific case of address, wouldn't any change I make then change the actual device address? All I want is to change the displayed address.

Posted on
Wed Sep 04, 2019 5:53 am
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: changing Device UI columns

I've never had to worry about that, but I reckon that this exposes the equivalent of the ui.state only.

Perhaps Jay or Matt could chime in on any associated risks...

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

[My Plugins] - [My Forums]

Posted on
Wed Sep 04, 2019 6:33 am
FlyingDiver online
User avatar
Posts: 7215
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: changing Device UI columns

Model and sub-model are easily changed:

Code: Select all
device.model = "Something"
device.subModel = "Something Else"
device.replaceOnServer()   


You can make the address field anything you want. But when you retrieve that field later in your code, you'll need to deal with what you set it to. Indigo doesn't care when you put in that field (for plugins).

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

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

Re: changing Device UI columns

FlyingDiver wrote:
Model and sub-model are easily changed:
Code: Select all
device.model = "Something"
device.subModel = "Something Else"
device.replaceOnServer()

Thanks. I wasn't aware model/subModel were writable. One question though. Since the device needs to exist before it can be updated, that would mean this cannot be done as part of the device configuration (where we only have valuesDict). Instead, we need to do it in deviceStartComm() or elsewhere where the device is available. In any case, that works for model.

However, unfortunately...
    exception in deviceStartComm(Dual Plug): the attribute "protocol" is read-only on this instance
    exception in deviceStartComm(Dual Plug): the attribute "address" is read-only on this instance
.

Posted on
Wed Sep 04, 2019 6:49 am
FlyingDiver online
User avatar
Posts: 7215
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: changing Device UI columns

berkinet wrote:
However, unfortunately...
    exception in deviceStartComm(Dual Plug): the attribute "protocol" is read-only on this instance
    exception in deviceStartComm(Dual Plug): the attribute "address" is read-only on this instance
.


You can't change protocol, that's the name of the plugin.

Address is changed as above, with the pluginProps.

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

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

Re: changing Device UI columns

FlyingDiver wrote:
...You can't change protocol, that's the name of the plugin.
Address is changed as above, with the pluginProps.

I got that I could change the "address" state to change the plugin dev.address. But, since the plugin actually uses this address (It is an IP address) I only wanted to change the displayed address in the Devices window, and not the address used internally for the connection. I pretty much figured it wasn't possible, but figured it was worth asking.

Though, now that I think about it. I could store the address in any form I wanted and then edit it in the plugin when it is used. So, maybe I have my answer.

Posted on
Wed Sep 04, 2019 6:57 am
FlyingDiver online
User avatar
Posts: 7215
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: changing Device UI columns

berkinet wrote:
Though, now that I think about it. I could store the address in any form I wanted and then edit it in the plugin when it is used. So, maybe I have my answer.


That's what I mean when I wrote "you'll need to deal with what you set it to".

And the device.address property is just a shortcut to device.pluginProps['address']. It's only stored once. There is no UI version. States have UI versions, not properties.

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

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

Re: changing Device UI columns

FlyingDiver wrote:
...That's what I mean when I wrote "you'll need to deal with what you set it to".

:oops: Sorry, I missed that.

Posted on
Wed Sep 04, 2019 8:12 am
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: changing Device UI columns

I am using another prop for the plain ip number. And address is a formatted ip number ( 3 digits for the last digit for better sorting)

EG
192.168.1.3 In other prop
192.168.1.003 in address Field, this sorts well

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests