Device state list items showing up as triggers?

Posted on
Sat Sep 29, 2018 12:13 pm
bap offline
Posts: 33
Joined: Sep 25, 2012

Device state list items showing up as triggers?

I'm working on updating an existing plugin of mine and I just added a new device state with a list of possible values. It's defined in my Devices.xml like this:

Code: Select all
            <State id="direction">
                <ValueType>
                    <List>
                        <Option value="forward">Forward (testing)</Option>
                        <Option value="reverse">Reverse (also testing)</Option>
                    </List>
                </ValueType>
                <TriggerLabel>Direction testing as well</TriggerLabel>
                <ControlPageLabel>Direction</ControlPageLabel>
            </State>


When I go into Indigo (just installed 7.2) and go to define a trigger for this device I now see not only the Direction as a trigger I can select, but the Forward and Reverse options as well:

Image

Whether I select Direction as a trigger or Forward/Reverse they all appear to be triggered when my plugin invokes dev.updateStateOnServer('direction', ...). no matter the value I update it to. Is this expected behavior? It seems confusing to me to have three separate triggers based upon the above state definition.

-Bruce

Posted on
Sat Sep 29, 2018 2:48 pm
matt (support) offline
Site Admin
User avatar
Posts: 21429
Joined: Jan 27, 2003
Location: Texas

Re: Device state list items showing up as triggers?

Swap out your 2 labels with the following 4 label definitions and I think it will make more sense:

Code: Select all
      <TriggerLabel>Direction Changed</TriggerLabel>
      <TriggerLabelPrefix>Direction Changed to</TriggerLabelPrefix>
      <ControlPageLabel>Direction</ControlPageLabel>
      <ControlPageLabelPrefix>Direction is</ControlPageLabelPrefix>

The first item it will show in the popup will be triggered when the direction state has any change, and others will trigger only when the state changes to that particular value (forward or reverse). When inspecting those states on a Control Page the first will be the value of the direction state, the latter two will be booleans on if the state are those particular (forward or reverse) values.

Image

Posted on
Sat Sep 29, 2018 6:22 pm
bap offline
Posts: 33
Joined: Sep 25, 2012

Re: Device state list items showing up as triggers?

Ah, thank you for that. It makes everything much clearer now!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest