Getting state name from devices

Posted on
Fri May 27, 2016 1:57 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Getting state name from devices

Is there a way to get state names from a device? For instance if I have a custom state called "foo" and have defined it in the plugin as "Value of Foo", is there a way I can read an indigo.devices device and pull that description out? Think triggers, when you pull up a device in the trigger list it doesn't show "foo", it shows "Value of Foo" and I would like to replicate that in my plugins so when I'm looking at device states I can present to the user the names of the states rather than the variable name itself.

I know that I can get the variable names from dev.states, is there a dev.statename or something like that? Or maybe a lookup "get name for state dev.states["foo"]"?

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Fri May 27, 2016 2:28 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Getting state name from devices

Great question. The answer though is that it isn't possible yet (from a plugin). We need to add it though...

Image

Posted on
Fri May 27, 2016 2:42 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Getting state name from devices

You're looking for a way to get the <TriggerLabel> or <ControlPageLabel> of the device state definition?

You should be able to get what you want using the getDeviceStateList() method. See http://wiki.indigodomo.com/doku.php?id= ... in_guide&s[]=getdevicestatelist

Yes, Matt, I know it's not designed for that, but....

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

Posted on
Fri May 27, 2016 2:50 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Getting state name from devices

@FlyingDiver, I believe the request is to get it for any device, not just devices that your plugin defines. getDeviceStateList() is a callback method that's only called by the server within the context of a plugin.

This is one of those rare enhancements that I really want for a variety of reasons, but because it's such a PITA to implement, we keep kicking it down the road... :wink:

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri May 27, 2016 2:59 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Getting state name from devices

Matt & Jay, thanks for the update - and, yes, FD & Jay, I'm looking for it across the board instead of just for my own plugins. Isn't there a database query tool? I wonder if that could be a workaround until an actual function is built for it - or perhaps the ability to query the database either isn't really there or doesn't get deep enough into the database to get state names.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Fri May 27, 2016 3:08 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Getting state name from devices

Yeah, the problem is it isn't in the database. Only the raw stateID's are stored there. The more verbose UI description is always retrieved by the Indigo Client directly before it shows the Trigger UI dialog by querying the plugin directly (via the getDeviceStateList() callback). So to fix this we need to cache off the information (in the database).

Image

Posted on
Fri May 27, 2016 3:09 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Getting state name from devices

Ok, I missed that this was for any random device. You could make it work for any plugin device that you control, by adding code to add those labels to the device plugin props, but not for any other device. Bummer.

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

Posted on
Sat May 28, 2016 6:52 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Getting state name from devices

I suppose it could be possible to do a simple XML read of the various plugin Device.xml files on the Indigo web server to parse the names for 3rd party plugins and build a Py function to resolve common non-3rd party plugin (such as knowing onOffState typically equals "On/off state". A bit of an undertaking and limiting but a possible workaround until there is something in Indigo 7 release 1 (evil grin).

It's not super critical, just a nicety so I totally understand why it gets back-burnered regularly.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest

cron