Question about plugin action conventions

Posted on
Thu Jul 27, 2017 9:33 pm
jon offline
Posts: 40
Joined: Jul 27, 2017

Question about plugin action conventions

I'm working on a plugin that I'm just about ready to share for feedback. I'm not sure I'm happy with my actions menu (see screenshot)

I started out adding a "set <foo>" action for each setting that enumerated the possible values for each setting, but as I've gone through the protocol documentation the list has gotten kind of unwieldy. While thinking about the least-random way to sort all the actions, I got to wondering if maybe there's a better way entirely?

Is there a clean way to have an action like "send picture command" that pops up a dialog where I can choose a command, which then populates possible values based on the command?

Or is a huge action list a reasonable thing to have?
Attachments
Screen Shot 2017-07-27 at 10.32.55 PM.png
Screen Shot 2017-07-27 at 10.32.55 PM.png (341.1 KiB) Viewed 2400 times

Posted on
Fri Jul 28, 2017 4:54 am
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Question about plugin action conventions

Take a look at the Sonos plugin. Nick's plugin shows how you can have sub-actions for your action items. I think that's the simplest approach if you just want to consolidate menu items.

You can also produce a dialog by adding a <configUi> element to the action item. Here's an example from the matplotlib plugin:
Code: Select all
<?xml version="1.0"?>
<Actions>
  <SupportURL>http://forums.indigodomo.com/viewforum.php?f=219</SupportURL>

  <Action id="refreshTheChartsAction">
    <Name>Redraw All Charts</Name>
    <CallbackMethod>refreshTheChartsAction</CallbackMethod>
  </Action>

  <Action id="refreshAChartAction">
    <Name>Redraw Single Chart</Name>
    <CallbackMethod>refreshAChartAction</CallbackMethod>
        <ConfigUI>
         <Field id="instructionsLabel" type="label" fontColor="black" fontSize="regular">
            <Label>Use this Action Item to select an individual chart to be refreshed.</Label>
         </Field>
            <Field id="chartToRefresh" type="menu" fontColor="black" fontSize="regular">
                <Label>Chart:</Label>
                <List class="self" filter="" method="getChartList" dynamicReload="true"/>
            </Field>
         <Field id="exampleLabel" type="label" fontColor="black" fontSize="small" alignWithControl="true">
            <Label>Only this chart will be refreshed when the Action Item is called. To refresh more charts, create additional Action Items.</Label>
         </Field>
        </ConfigUI>
  </Action>

  <Action id="refreshTheChartsAPI" uiPath="hidden">
    <Name>API Action to Draw Simple Chart</Name>
    <CallbackMethod>plotActionTest</CallbackMethod>
  </Action>

</Actions>

Note that the third action item is hidden and does not appear in the actions menu.

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

[My Plugins] - [My Forums]

Posted on
Fri Jul 28, 2017 8:42 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Question about plugin action conventions

What you want to look at is the dynamic menu/lists. All of the current values from the dialog are sent to the method that generates the dynamic menu. So that method can inspect the menu that specifies the specific command and build the appropriate list. You can also mark the field as dynamicReload such that when the command menu changes it automatically calls the method to regenerate the menu/list.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Jul 28, 2017 9:49 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Question about plugin action conventions

Just a note that Jay's post about dynamic menu/lists is also talking about using <ConfigUI> to have a sub-action type in the dialog based on some main category types you would specify. Point being, you cannot dynamically change the action types shown in the main Action panel popup.

Image

Posted on
Fri Jul 28, 2017 4:47 pm
jon offline
Posts: 40
Joined: Jul 27, 2017

Re: Question about plugin action conventions

OK, cool. I saw some of the docs about ConfigUI but I wasn't making the connection to what I'm trying to do. Thanks for the pointers.

Posted on
Sat Jul 29, 2017 8:43 pm
jon offline
Posts: 40
Joined: Jul 27, 2017

Re: Question about plugin action conventions

I tried rolling a bunch of related enum-valued commands into a compound action. I have all the commands enumerated in the "command" field, and I was *hoping* my valueGenerator function would be called to populate the options for the "value" field whenever the selection changes.

What's actually happening is it gets called once when the dialog is drawn so the values never change.

Am I missing something here, or just barking up the wrong tree entirely?

Code: Select all
   <Action id="setPictureOption" deviceFilter="self">
      <Name>Set Picture Option</Name>
      <CallbackMethod>enumAction</CallbackMethod>
      <ConfigUI>
         <Field id="Command" type="menu" defaultValue="AutoMotionPlus">
            <Label>Picture Command:</Label>
            <List>
               <Option value="BlackTone">Black Tone</Option>
               <Option value="DynamicContrast">Dynamic Contrast</Option>
               <Option value="RGBOnlyMode">RGB-Only Mode</Option>
               <Option value="ColorSpace">Color Space</Option>
               <Option value="EdgeEnhancement">EdgeEnhancement</Option>
               <Option value="xvYCC">xvYCC</Option>
               <Option value="MotionLighting">Motion Lighting</Option>
               <Option value="LEDMotionPlus">LED Motion Plus</Option>
               <Option value="ColorTone">Color Tone</Option>
               <Option value="DigitalNoiseFilter">Digital Noise Filter</Option>
               <Option value="MPEGNoiseFilter">MPEG Noise Filter</Option>
               <Option value="HDMIBlackLevel">HDMI Black Level</Option>
               <Option value="FilmMode">Film Mode</Option>
               <Option value="AutoMotionPlus">Auto-Motion Plus</Option>
               </List>
           </Field>
         <Field id="Value" type="menu" defaultValue="">
            <List class="self" filter="test" method="commandValueGenerator" dynamicReload="true"/>
         </Field>
      </ConfigUI>
   </Action>

Posted on
Sun Jul 30, 2017 3:50 am
FlyingDiver offline
User avatar
Posts: 7221
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Question about plugin action conventions

You need a "<CallBackMethod>" in the first field description as well, to force the menu to update when it changes.

Code: Select all
   <Action id="setPictureOption" deviceFilter="self">
      <Name>Set Picture Option</Name>
      <CallbackMethod>enumAction</CallbackMethod>
      <ConfigUI>
         <Field id="Command" type="menu" defaultValue="AutoMotionPlus">
            <Label>Picture Command:</Label>
            <List>
               <Option value="BlackTone">Black Tone</Option>
               <Option value="DynamicContrast">Dynamic Contrast</Option>
               <Option value="RGBOnlyMode">RGB-Only Mode</Option>
               <Option value="ColorSpace">Color Space</Option>
               <Option value="EdgeEnhancement">EdgeEnhancement</Option>
               <Option value="xvYCC">xvYCC</Option>
               <Option value="MotionLighting">Motion Lighting</Option>
               <Option value="LEDMotionPlus">LED Motion Plus</Option>
               <Option value="ColorTone">Color Tone</Option>
               <Option value="DigitalNoiseFilter">Digital Noise Filter</Option>
               <Option value="MPEGNoiseFilter">MPEG Noise Filter</Option>
               <Option value="HDMIBlackLevel">HDMI Black Level</Option>
               <Option value="FilmMode">Film Mode</Option>
               <Option value="AutoMotionPlus">Auto-Motion Plus</Option>
               </List>
           <CallbackMethod>menuChanged</CallbackMethod>
         </Field>
         <Field id="Value" type="menu" defaultValue="">
            <List class="self" filter="test" method="commandValueGenerator" dynamicReload="true"/>
         </Field>
      </ConfigUI>
   </Action>

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

Posted on
Sun Jul 30, 2017 10:47 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Question about plugin action conventions

So, to summarize, to create a menu (or list) that changes based on the value of another menu (or list) when it's selection is changed, you need the fields defined in the ConfigUI element of any dialog:

Code: Select all
<Field id="fixedMenu" type="menu" defaultValue="one">
   <Label>Fixed Menu Selections:</Label>
   <List>
      <Option value="one">One</Option>
      <Option value="two">Two</Option>
   </List>
   <CallbackMethod>doNothingMethod</CallbackMethod>
</Field>
<Field id="fixedMenuDependency" type="menu">
   <Label>Dynamic Menu Selections:</Label>
   <List class="self" method="dynamicMenuGenerator" dynamicReload="true"/>
</Field>


and you need the following 2 methods defined in your plugin.py:

Code: Select all
def doNothingMethod(self, valuesDict, typeId="", devId=None):
    # This method doesn't do anything itself, but it's existence forces the
    # dynamicMenuGenerator method below to get called.
    self.debugLog("doNothingMethod called")

def dynamicMenuGenerator(self, filter="", valuesDict=None, typeId="", devId=None):
    self.debugLog("dynamicMenuGenerator called")
    return_list = [
            ("1", "1"),
            ("one", "One"),
            ("uno", "Uno"),
            ("un", "Un"),
            ("ein", "Ein"),
        ]
    if valuesDict.get("fixedMenu", None) == "two":
        return_list = [
            ("2", "2"),
            ("two", "Two"),
            ("dos", "Dos"),
            ("deux", "Deux"),
            ("zwei", "Zwei"),
        ]
    return return_list


This will work even if the first menu (or list, or any combination) is dynamic as well.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jul 31, 2017 6:29 am
jon offline
Posts: 40
Joined: Jul 27, 2017

Re: Question about plugin action conventions

Thanks for all the help. I've got it working and the newly simplified actions list looks a lot less intimidating.

Just have a few more loose ends to clean up before a public beta release.

Posted on
Tue Aug 01, 2017 9:43 pm
jon offline
Posts: 40
Joined: Jul 27, 2017

Re: Question about plugin action conventions

It's not *done* exactly, but I think it's at a point where I'm not embarrassed to share with the group

https://github.com/eklundjon/indigo-exlink

Posted on
Wed Aug 02, 2017 3:58 am
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Question about plugin action conventions

Congrats on your first plugin. There's something hinky with your Github release as the plugin source isn't visible and your release page is empty.

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

[My Plugins] - [My Forums]

Posted on
Wed Aug 02, 2017 9:43 am
jon offline
Posts: 40
Joined: Jul 27, 2017

Re: Question about plugin action conventions

Oh, thanks for pointing that out. I put a link to releases in my readme and forgot to actually make the release after pushing it. Probably not the only thing I forgot :)

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests