[ANSWERED]: About Custom Device States

Posted on
Mon Oct 26, 2015 6:41 am
wickey offline
Posts: 22
Joined: Feb 15, 2015

[ANSWERED]: About Custom Device States

Hi,

Im here again with another question :)

for my custom device I am having custom status as below.
<States>
<State id="playStatus">
<ValueType>
<List>
<Option value="not_playing">Not Playing</Option>
<Option value="playing">Playing</Option>
</List>
</ValueType>
----
</State>
<States>

Since we can't have spaces in option value, I have added the "_". When plugin detects status change I update using
device.updateStateOnServer("playStatus", "not_playing"). Then plugin works fine, but in custom states of that device , value shows as "not_playing" with underscore. In Indigo Touch also it shows as the same way. I don't like it much. How can I get "Not Playing" rather than showing "not_playing".

device.updateStateOnServer("playStatus", "Not Playing") gives "invalid enumeration value" Error.

Posted on
Mon Oct 26, 2015 6:55 am
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: About Custom Device States

How can I get "Not Playing" rather than showing "not_playing".

The way to change the display that is shown in the State column of the Mac client and in Indigo Touch is to use the uiValue parameter when updating the state:
Code: Select all
dev.updateStateOnServer("playStatus", "not_playing", uiValue=u'Not Playing')
Note that all triggers and actions and such will still use "not_playing", this just affects what is shown in the display field(s).

Adam

Posted on
Mon Oct 26, 2015 11:48 pm
wickey offline
Posts: 22
Joined: Feb 15, 2015

Re: [ANSWERED]: About Custom Device States

Thank You very much.. It is working for ui values in indigo touch and in status column in indigo mac client, but under Custom Status box ( in indigo mac client ) still shows not_playing.

Is it expected behaviour?

Posted on
Tue Oct 27, 2015 3:36 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: [ANSWERED]: About Custom Device States

wickey wrote:
Thank You very much.. It is working for ui values in indigo touch and in status column in indigo mac client, but under Custom Status box ( in indigo mac client ) still shows not_playing.

Is it expected behaviour?

Do you mean here?
Screen Shot 2015-10-27 at 4.21.34 AM.png
Screen Shot 2015-10-27 at 4.21.34 AM.png (27.1 KiB) Viewed 1915 times

As you can see, it is possible to have spaces in a custom state value. What I think you are seeing is a Python idiom for parameter values. Because you are establishing a list element In your device's XML, you are setting the default parameter values for a method call and (as far as I recall) spaces are not allowed for parameters.) in other words,

Code: Select all
maximumFoo(self, parameter1="this_is_allowable", parameter2="this is not allowable")

"not_playing" is the actual value of the state, and that's what is being displayed in the Custom Device States window. As far as I know, it isn't possible to display the uiValue in the Custom States window.

Dave

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

[My Plugins] - [My Forums]

Posted on
Tue Oct 27, 2015 7:57 am
wickey offline
Posts: 22
Joined: Feb 15, 2015

Re: [ANSWERED]: About Custom Device States

Yes I meant there.

Yes it is possible to have states with spaces when the value type is a string. But when it becomes list it was not possible.

Anyways, I am satisfied with UiValue.

Thank you very much for quick replies and your comments helped me lot.

Posted on
Tue Oct 27, 2015 10:20 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: [ANSWERED]: About Custom Device States

wickey wrote:
Is it expected behaviour?


In a word, yes. Enumerated state types aren't yet really used well, and this is one area where it falls down a bit.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests