[ANSWERED]: Best way to check if a device object is a sensor

Posted on
Sun Apr 03, 2016 10:39 pm
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

[ANSWERED]: Best way to check if a device object is a sensor

Given an indigo.Device object, what is the best way to check whether that device is a sensor device (in the sense of the "indigo.sensor" filter)? I don't see a property method that helps with that question. The best I can come up with is

Code: Select all
device.id in indigo.devices.iterkeys("indigo.sensor")
which I suspect is not terribly efficient if there are many devices. Is there a better way?

And how do I check whether a device is a plugin "custom" device? More generally, how do I figure out what the plugin author said the Device type="xxx" value was?

Cheers
-- perry

Posted on
Wed Apr 06, 2016 9:45 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Best way to check whether a device object is a sensor

Actually, that above is a good technique. The iterkeys with filter argument method actually runs inside the Indigo Server process, so it only hands off to the client the device instances that match the filter, and thus is much more efficient than iterating over all the devices from the plugin process.

Filtering on specific plugin custom device types is more problematic though. You can use iterkeys() to filter on all devices defined by a given plugin, but you cannot specify the device type ID on which to filter. So that has to be done manually. Good feature request though. 8)

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests