UI to build lookup table

Posted on
Tue Aug 24, 2021 1:43 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

UI to build lookup table

The new Phidgets plugin uses serial numbers to identify the device (s) Indigo communicates with, and which attach to the individual sensors. I use the serial number as part of the Indigo device address. However, labels are not very mnemonic, so I would like to allow the user to assign labels to these serial numbers. This would probably be part of the plugin-config, though it could be a separate config menu entry. My question is about how to do this. Ideally, I would like two side-by-side columns of text fields.
Like:
Code: Select all
Serial Number -- Label
[123456]         [DOhub]
[345678]         [DIhub1]
Etc.
But, as I have no idea how to do that in Indigo's UI, I am very open to ideas.

Posted on
Tue Aug 24, 2021 4:08 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: UI to build lookup table

I don't use Phidgets, but do you create an Indigo device for each Phidget device? If so, why keep a separate list? The name of the device is already there.

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

Posted on
Tue Aug 24, 2021 5:14 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: UI to build lookup table

FlyingDiver wrote:
… If so, why keep a separate list? The name of the device is already there.
Phidget sensors and controllers, in other words, things that interact with the real world, are instantiated in Indigo as devices. However, these real devices may or may not connect directly to Indigo. So, the device address column should show the path to the actual device. And, there is always ultimately an element with a serial number involved, and that serial number is a necessary device property. it may belong to the device itself, or some other device the real device connects to. For example, the Indigo device address might be port 3, channel 2 on device serial number 1234.

I am already creating that address using the serial number. Eg 1245:p1-c4. I just wanted to use a more human friendly label in its place. Eg. hub2:p1-c4

Posted on
Tue Aug 24, 2021 6:16 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: UI to build lookup table

I don't see the upside to the user to make the address field more "user friendly". But if that's what you really want to do, you could do it with a popup for the devices not yet named, and a field to enter the name, then a list to represent the already assigned names. Like the older Alexa Hue plugin did, or my LIFX Bridge plugin (which stole the code from the Alexa Hue).

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

Posted on
Tue Aug 24, 2021 6:22 pm
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: UI to build lookup table

Right now, the only thing I can think of within the Indigo UI structure is to use a list box control to list the Phidgets devices' serial number and label and a text fields to edit the label. Click on the device in the list and populate the label field. The user could add (or change) the label field and select a button to save changes. Without a monospace font, I think decent columns might be tough in the list box, but you could separate with something like a hyphen or brackets or something.

The only other thing I can think of is to use the new Web Server capabilities to construct a web page to display and edit the label. This would limit the feature to users on Indigo 2021.1+.

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

[My Plugins] - [My Forums]

Posted on
Wed Aug 25, 2021 7:55 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: UI to build lookup table

Thanks for the ideas. I think either could work. But, before I head down that road, I found another way: SImply create a variable named with a specific prefix and the serial number.

For example: p22_618455 = Kitchen-Hub

Not very slick or cool, but quite workable, for now anyway.

And, a related question... is there a variable command similar to device.pluginProps.get("foo", 0). Where a default value can be set? I know there is var.getValue(bool|int|float). But that doesn't really do what I need. No big deal. without such a command, I need to wrap getting the variable in a try: block.

Posted on
Wed Aug 25, 2021 8:28 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: UI to build lookup table

I wrote:
.... is there a variable command similar to device.pluginProps.get("foo", 0). Where a default value can be set?...
I just found an old post from DaveL17, so...
Code: Select all
if varName in indigo.variables:
            addrIndex = str(indigo.variables[varName].value)

Posted on
Wed Aug 25, 2021 8:55 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: UI to build lookup table

+1 on Joe's suggestion - it's basically the master-detail design pattern that's been around for years and I think users can intuit how it works pretty easily. Also, you can use the code from either of the mentioned plugins and just modify it to suit your needs.

I don't think using a variable is very user-friendly (less intuitive), but...

berkinet wrote:
I need to wrap getting the variable in a try: block.


That would be the most pythonic way, and would solve another issue:

Code: Select all
try:
    addr_name = indigo.variables[varName].value
    # This will check for an empty string just to make sure the user didn't create the variable but leave the value blank
    if not addr_name:
        raise
except:
    # use the default or whatever
    addr_name = #whatever the actual address is


That should always set addr_name so that it's usable afterward in the code.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Aug 25, 2021 10:22 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: UI to build lookup table

jay (support) wrote:
...I don't think using a variable is very user-friendly (less intuitive), but...
... That would be the most pythonic way, and would solve another issue...
The problem with the approach Joe suggests is that for this particular plugin there are many more indigo devices than actual real-world devices with serial numbers. For example, a Phidgets 8/8/8 interface kit has a total of 24 ports. So, instead of entering a serial number to label lookup once, it would have to be done up to 24 times. Also, while the user must manually enter the serial number now, it is actually possible to do that automatically and I may add that at some future point.

Good point on the null variable value, thanks.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests