Determine a device's deviceTypeId?

If I have a device object, is there a way I can get the device Type ID (hash that represents the device type ID)?

With that ID I figure I could do a mapping to determine if a “switch” is a zwave switch vs anything else that has “switch” capabilities (like a sonos).

Pardon this indirect answer for now… (it’s typical CosmicPuppy answer…):

I presume you are referring to from within a SmartApp?

Inside a SmartApp, the device instances you access are instances of class Device. Refer to Reference Material here: https://graph.api.smartthings.com/ide/doc/device ; but, note that there may be undocumented methods and attributes.

(NB: You are not accessing the class SmartDevice Type, even though they have some similar attributes and methods).

Based on the attributes and methods of Device, I am not sure you can determine lower level characteristics*, or even the data from the “factory” SmartDevice Type class that instantiated the Device. * Except you CAN ask it for it’s list of “capabilities.*”.

But, I must stress this: You are not supposed to. The Device is a instantiated interface to the physical Thing. It is an abstraction. If SmartApps started making assumptions or starting prying into the detailed nature of the real-world Thing, then the isolation between SmartApps and Things would break. All the information you need must and can only come from Device’s reported Capabilities.

If a Sonos has capability.switch, then, yes, indeed, any SmartApp that can turn a light on and off could also turn the Sonos on and off. If someone wrote a SmartApp that detected it was a Sonos (rather than checking for capability.musicPlayer and decided to play music on it, then that SmartApp would fail to work with non-Sonos players and other Music Playing SmartApps would have to share that “cheating” peek into the Device Type).

When used according to spec, we should be able to swap-out one Thing for another Thing completely seamlessly (i.e., breaking zero SmartApps), if and only if they have the exact same Capabilities.

@matthewnohr may confirm, clarify, or correct me? – but I welcome your comments and questions.

…CP / Terry.

Thanks Terry.
Yep, I’ve been through the docs… and have discovered an undocumented method or two (device.hub.id/device.hub.name, for instance). I was hoping to find one to let me unobstract. Without that, yes, I can compare a list of capabilities and go from there.
Thanks for the reply!
-Kris

1 Like