HELP!

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo
Forum rules
This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo
User avatar
berkinet
Posts: 3441
Joined: Tue Nov 18, 2008 2:08 pm
Location: Berkeley, CA, USA & Mougins, France

HELP!

Post by berkinet »

Ok, this serious non-OO coder is trying to get the hang of the new paradigm. It was going fairly well until I tried to creative a dynamic list in Devices.xml, like:

Code: Select all

<Field id="analog0" type="menu" defaultValue="sensor-0">
  <Label>Input 0:</Label>
    <List>
        <List class="self" method="phidgetSensorsList" />
    </List>
</Field>
My method, phidgetSensorsList, is declared in plugin.py as:

Code: Select all

	def phidgetSensorsList(self, filter="", ValuesDict="None", typeId="", targetId=0):
		csvfile = open('/Users/rdp/phidgets-sensors.txt')
		sensorOptions = [ row.strip().split(',') for row in csvfile]
		return (sensorOptions)
When I get to the point in the create device dialog where the list is loaded, I get:
Error (client) runDialogForDevice() caught exception: Dynamic <List> elements must contain a class attribute. -- filter with no class: (null)

The list I am passing in looks like:

Code: Select all

[['sensor-0', ' -- None --'], ['sensor-1', '1101 - IR Distance Adapter'], ['sensor-2', '1102 - IR Reflective Sensor 5mm'], ['sensor-3', '1103 - IR Reflective Sensor 10cm'], ['sensor-4', '1104 - Vibration Sensor'], ['sensor-5', '1105 - Light Sensor'], ['sensor-6', '1106 - Force Sensor'], ['sensor-7', '1107 - Humidity Sensor'], ['sensor-8', '1108 - Magnetic Sensor'], ['sensor-9', '1109 - Rotation Sensor'], ['sensor-10', '1110 - Touch Sensor'], ['sensor-11', '1111 - Motion Sensor'], ['sensor-12', '1112 - Slider 60'], ['sensor-13', '1113 - Mini Joy Stick Sensor'], ['sensor-14', '1114 - Temperature Sensor'], ['sensor-15', '1115 - Pressure Sensor'], ['sensor-16', '1116 - Multi-turn Rotation Sensor'], ['sensor-17', '1117 - Voltage Sensor'], ['sensor-18', '1118 - 50Amp Current Sensor AC+DC'], ['sensor-19', '1119 - 20Amp Current Sensor AC+DC'], ['sensor-20', '1120 - FlexiForce Adapter'], ['sensor-21', '1121 - Voltage Divider'], ['sensor-22', '1122 - 30 Amp Current Sensor AC+DC'], ['sensor-23', '1123 - Precision Voltage Sensor'], ['sensor-24', '1124 - Precision Temperature Sensor'], ['sensor-25', '1125 - Humidity/Temperature Sensor'], ['sensor-26', '1126 - Differential Gas Pressure Sensor'], ['sensor-27', '1127 - Precision Light Sensor'], ['sensor-28', '1128 - MaxBotix EZ-1 Sonar Sensor'], ['sensor-29', '1129 - Touch Sensor'], ['sensor-30', '1130 - pH/ORP Adapter'], ['sensor-31', '1131 - Thin Force Sensor'], ['sensor-32', '1132 - 4-20mA Adapter'], ['sensor-33', '1133 - Sound Sensor'], ['sensor-34', '1134 - Switchable Voltage Divider'], ['sensor-35', '1135 - Precision Voltage Sensor']]
BTW, this works fine if I enter the same text manually into the List definition.

I know I am doing something wrong, but, for the life of me, I cannot figure out what.
User avatar
matt (support)
Site Admin
Posts: 21542
Joined: Mon Jan 27, 2003 1:17 pm
Location: Texas
Contact:

Re: HELP!

Post by matt (support) »

Your Field node has a List inside of a List, so remove the outer most List definition:

Code: Select all

    <Field id="analog0" type="menu" defaultValue="sensor-0">
      <Label>Input 0:</Label>
        <List class="self" method="phidgetSensorsList" />
    </Field>
Image
User avatar
berkinet
Posts: 3441
Joined: Tue Nov 18, 2008 2:08 pm
Location: Berkeley, CA, USA & Mougins, France

Re: HELP!

Post by berkinet »

DOH! It's amazing how long I looked at that and just didn't see what was right in front of my eyes.

Thanks Matt.
User avatar
berkinet
Posts: 3441
Joined: Tue Nov 18, 2008 2:08 pm
Location: Berkeley, CA, USA & Mougins, France

Re: HELP!

Post by berkinet »

Moving ahead in tiny steps... My field definition is now:
  • <Field id="analog0" type="menu" defaultValue="sensor-0">
    • <Label>Input 0:</Label>
      <List class="self" method="phidgetSensorsList" />
  • </Field>
And it seems to generally work as intended, with one exception. The defaultValue is ignored and in its place, the default label of " - no selection - " is used. For this plugin it is ok to not have a selection, but the word "None" is more meaningful, since there is No sensor attached. Is there anyway to alter the default entry/label for dynamic lists?
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: HELP!

Post by jay (support) »

No way to change it currently. I'll add it to the feature request list.
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
nlagaros
Posts: 1646
Joined: Mon Dec 20, 2010 2:16 pm

Re: HELP!

Post by nlagaros »

I see this defaultValue issue is still the case with Indigo 6. Any update on it?
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: HELP!

Post by jay (support) »

Nope - and in all honesty it isn't super high on the list. Do you have an example that might make it a higher priority?
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
nlagaros
Posts: 1646
Joined: Mon Dec 20, 2010 2:16 pm

Re: HELP!

Post by nlagaros »

I have several actions in my Sonos plugin that could benefit from this. For example, I have an action that has 12 lists that allow one to add ZonePlayers to a Group. By default, the Indigo "--no selection--" is selected, it would be convenient for me to use my own "No Selection" option. When I iterate through the inputs, I can look for that one selection, vs. having to check for mine and the Indigo default.

It is not the highest priority by any means - just a convenience thing.
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: HELP!

Post by jay (support) »

So you have a "No Selection" option as well as the default "- no selection -" option? Just trying to understand a little more clearly.
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
User avatar
berkinet
Posts: 3441
Joined: Tue Nov 18, 2008 2:08 pm
Location: Berkeley, CA, USA & Mougins, France

Re: HELP!

Post by berkinet »

I believe the issue here is that while "--No Selection--" represents a null choice, "No Selection" is, in fact, a choice.
nlagaros
Posts: 1646
Joined: Mon Dec 20, 2010 2:16 pm

Re: HELP!

Post by nlagaros »

If one selects a true menu item and then changes their mind, they will no longer have the option of using the Indigo "--no selection'--". That disappears, so the user would have to create a brand new action if they want to negate that particular menu option. The issue is that the menu selections are optional. In my case, the user can select up to 12.
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: HELP!

Post by jay (support) »

nlagaros wrote:If one selects a true menu item and then changes their mind, they will no longer have the option of using the Indigo "--no selection'--". That disappears, so the user would have to create a brand new action if they want to negate that particular menu option. The issue is that the menu selections are optional. In my case, the user can select up to 12.
Ah, I see, that makes a lot more sense. Seems like these are the options that would be nice to have on all popup fields:
  • Specify a default value (tricky on dynamic fields since they are, well, dynamic[/i - should probably allow a flag to select the 1st item regardless of what it is)
  • Specify text for a "null" selection (mainly for UI customization)
  • Specify if a "null" selection is always available (which would take care of your use case)


I'll think more on this though I'm not sure if we'll get it in to Indigo 6 GM - we'll just have to see.
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
Locked

Return to “Extending Indigo with Plugins and Python”